home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Tools / MABuildTool.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  97.0 KB  |  3,735 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // MABuildTool.cp
  3. // Copyright © 1985-96 by Apple Computer, Inc. All rights reserved.
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UCPLUSTOOL__
  7. #include "UCPlusTool.h"
  8. #endif
  9.  
  10. // MacApp
  11.  
  12. #ifndef __MACAPPVERSION__
  13. #include "MacAppVersion.h"
  14. #endif
  15.  
  16. #ifndef __UASSOCIATION__
  17. #include "UAssociation.h"
  18. #endif
  19.  
  20. #ifndef __ULIST__
  21. #include "UList.h"
  22. #endif
  23.  
  24. #ifndef __USTRINGHANDLE__
  25. #include "UStringHandle.h"
  26. #endif
  27.  
  28. // Toolbox
  29.  
  30. #ifndef __RESOURCES__
  31. #include <Resources.h>
  32. #endif
  33.  
  34. // MPW
  35.  
  36. #ifndef __INTENV__
  37. #include <IntEnv.h>
  38. #endif
  39.  
  40.  
  41. //========================================================================================
  42. // CONSTANTS
  43. //========================================================================================
  44.  
  45. //----------------------------------------------------------------------------------------
  46. // Resource IDs
  47. //----------------------------------------------------------------------------------------
  48.  
  49. const short kHelpStr                = 129;    // Resource ID of the stringlist printed for help
  50.  
  51. //----------------------------------------------------------------------------------------
  52. // Keyword IDs
  53. //----------------------------------------------------------------------------------------
  54. //    set i 0
  55. //    loop
  56. //        find Δ/'= '[0-9]+';'/
  57. //        break if {status}
  58. //        replace /[0-9]+/ "{i}"
  59. //        evaluate i={i}+1
  60. //    end
  61.  
  62. enum
  63. {
  64.     kwUnspecified,
  65.     
  66.     kwAsm,
  67.     kwBuildFlags,
  68.     kwBuildFolder,    // Optional folder to place the object folders for a build in
  69.     kwC,
  70.     kwCP,
  71.     kwCPlusPlus,
  72.     kwCreatorAndBundle,
  73.     kwd,
  74.     kwE,
  75.     kwFat,
  76.     kwFolderName,
  77.     kwOutputFile,
  78.     
  79.     kwLib,
  80.     kwLink,
  81.     kwMake,
  82.     kwMakeSym,
  83.     kwMrC,
  84.     kwMWC68K,
  85.     kwMWLink68K,
  86.     kwMWCPPC,
  87.     kwMWLinkPPC,
  88.     kwPPCAsm,
  89.     kwPPCLib,
  90.     kwPPCLink,
  91.     kwR,
  92.     kwRAMDisk,
  93.     kwRenameFlag,
  94.     kwRez,
  95.     kwRSRC,
  96.     kwS,
  97.     kwSCpp,
  98.     kwSymantec,
  99.     kwVersion,
  100.     
  101.     kwAlign,
  102.     kwNoAlign,
  103.     
  104.     kwAttachable,
  105.     kwNoAttachable,
  106.     
  107.     kwAutoBuild,
  108.     kwNoAutoBuild,
  109.     
  110.     kwClassic,
  111.     kwNoClassic,
  112.     
  113.     kwContainer,
  114.     kwNoContainer,
  115.     
  116.     kwCPlusLoad,
  117.     kwNoCPlusLoad,
  118.     
  119.     kwDebug,
  120.     kwNoDebug,
  121.     
  122.     kwDebugMsg,
  123.     kwNoDebugMsg,
  124.     
  125.     kwDeluxe,
  126.     kwNoDeluxe,
  127.     
  128.     kwDrag,
  129.     kwNoDrag,
  130.     
  131.     kwExecute,
  132.     kwNoExecute,
  133.     
  134.     kwExpandEnvVars,
  135.     kwNoExpandEnvVars,
  136.     
  137.     kwFail,
  138.     kwNoFail,
  139.     
  140.     kwFast,
  141.     kwNoFast,
  142.     
  143.     kwGXPrinting,
  144.     kwNoGXPrinting,
  145.     
  146.     kwGXViews,
  147.     kwNoGXViews,
  148.     
  149.     kwInspector,
  150.     kwNoInspector,
  151.     
  152.     kwLinkMap,
  153.     kwNoLinkMap,
  154.     
  155.     kwLinkXRef,
  156.     kwNoLinkXRef,
  157.     
  158.     kwMacApp,
  159.     kwNoMacApp,
  160.     
  161.     kwMALibrary,
  162.     kwNoMALibrary,
  163.     
  164.     kwModelCFM,
  165.     kwNoModelCFM,
  166.     
  167.     kwModelFar,
  168.     kwNoModelFar,
  169.     
  170.     //CW added
  171.     kwModelFarCode,
  172.     kwNoModelFarCode,
  173.     
  174.     //CW added
  175.     kwModelFarData,
  176.     kwNoModelFarData,
  177.     
  178.     kwNames,
  179.     kwNoNames,
  180.     
  181.     kwNeedsColorQD,
  182.     kwNoNeedsColorQD,
  183.     
  184.     kwNeedsFPU,
  185.     kwNoNeedsFPU,
  186.     
  187.     kwNeedsGX,
  188.     kwNoNeedsGX,
  189.     
  190.     kwNeedsMC68020,
  191.     kwNoNeedsMC68020,
  192.     
  193.     kwNeedsMC68030,
  194.     kwNoNeedsMC68030,
  195.     
  196.     kwNeedsMC68040,
  197.     kwNoNeedsMC68040,
  198.     
  199.     kwNeedsSystem7,
  200.     kwNoNeedsSystem7,
  201.     
  202.     kwNeedsSystem7_5,
  203.     kwNoNeedsSystem7_5,
  204.     
  205.     kwNeedsVU,    // Optional Virtual User support.
  206.     kwNoNeedsVU,
  207.     
  208.     kwPerform,
  209.     kwNoPerform,
  210.     
  211.     kwPowerTalk,
  212.     kwNoPowerTalk,
  213.     
  214.     kwPP,
  215.     kwNoPP,
  216.     
  217.     kwRangeCheck,
  218.     kwNoRangeCheck,
  219.     
  220.     kwRun,
  221.     kwNoRun,
  222.     
  223.     kwSave,
  224.     kwNoSave,
  225.     
  226.     kwSeparateObjects,
  227.     kwNoSeparateObjects,
  228.     
  229.     kwSmallSym,
  230.     kwNoSmallSym,
  231.     
  232.     kwStatusOnly,
  233.     kwNoStatusOnly,
  234.     
  235.     kwSym,
  236.     kwNoSym,
  237.     
  238.     kwTemplateViews,
  239.     kwNoTemplateViews,
  240.     
  241.     kwTheDebugger,    // Optional The Debugger support
  242.     kwNoTheDebugger,
  243.     
  244.     kwTT,
  245.     kwNoTT,
  246.     
  247.     kwUserAutoBuild,
  248.     kwNoUserAutoBuild,
  249.     
  250.     kwWriteTemplateViews,
  251.     kwNoWriteTemplateViews
  252. };
  253.  
  254. //========================================================================================
  255. // CLASS TMABuildTool
  256. //========================================================================================
  257.  
  258. class TMABuildTool : public TCPlusTool
  259. {
  260.     MA_DECLARE_CLASS;
  261.  
  262.   protected:
  263.     Boolean fGetBuildFlags;
  264.     Boolean fGetFolderName;
  265.     
  266.     Boolean fMacApp;
  267.  
  268.     Boolean fDebug;
  269.     Boolean fInspector;
  270.     Boolean fDebugMsg;
  271.     Boolean fNames;
  272.     Boolean fRangeCheck;
  273.     Boolean fPerform;
  274.     Boolean fSym;
  275.     Boolean fSmallSym;
  276.     Boolean fAlign;
  277.     Boolean fAttachable;
  278.     Boolean fSeparateObjects;
  279.     CStr255 fSeparateObjectsFolder;
  280.     CStr255 fBuildFolder;
  281.     CStr255 fMAObj;
  282.     Boolean fMALibrary;
  283.     Boolean fCPlusLoad;                    // Create load/dump files for C++
  284.  
  285.     Boolean fModelFar;
  286. //CW added
  287.     Boolean fModelFarCode;
  288.     Boolean fModelFarData;
  289.  
  290.     Boolean fNeedsColorQD;
  291.     
  292.     // Kind of CPU
  293.     Boolean fNeedsMC68020;
  294.     Boolean fNeedsMC68030;
  295.     Boolean fNeedsMC68040;
  296.     Boolean fPowerPC;
  297.     
  298.     Boolean fNeedsFPU;
  299.     
  300.     Boolean fNeedsSystem7;
  301.     Boolean fNeedsSystem7_5;
  302.     
  303.     Boolean fTemplateViews;
  304.     Boolean fWriteTemplateViews;
  305.  
  306.     Boolean fAllProgress;
  307.     Boolean fExecute;
  308.     Boolean fAutoBuild;
  309.     Boolean fUserAutoBuild;
  310.     Boolean fNoFail;
  311. //CW added
  312.     Boolean fFast;
  313.     Boolean fLinkMap;
  314.     Boolean fLinkXRef;
  315.     Boolean fStatusOnly;
  316.     Boolean fTimes;
  317.     Boolean fRunAfterBuild;
  318.     Boolean fSaveBeforeBuild;
  319.     Boolean fExpandEnvironmentVars;
  320.  
  321.     Boolean fEverExported;                // only need to export once
  322.     
  323.     Boolean fNeedsVU;                    // Virtual User option.
  324.  
  325.     Boolean fTheDebugger;                // The Debugger option.
  326.     
  327.     Boolean fClassic;
  328.     Boolean fModelCFM;
  329.     Boolean fRSRC;
  330.     
  331.     Boolean fFat;
  332.     Boolean fRAMDisk;
  333.     
  334.     Boolean fDrag;
  335.     Boolean fGXViews;
  336.     Boolean fGXPrinting;
  337.     Boolean fNeedsGX;
  338.     Boolean fPowerTalk;
  339.     
  340.     Boolean fContainer;
  341.     
  342.     short fCompiler;
  343.  
  344.     CStr255 fAppName68K;
  345.     CStr255 fRAMDiskName;
  346.     
  347.     TStringHandle* fAsmOptions;
  348.     TStringHandle* fEchoOptions;
  349.     TStringHandle* fLibOptions;
  350.     TStringHandle* fLinkOptions;
  351.  
  352.     TStringHandle* fCOptions;
  353. //CW added
  354.     TStringHandle* fMWC68KOptions;
  355.     TStringHandle* fMWLink68KOptions;
  356.     TStringHandle* fMWCPPCOptions;
  357.     TStringHandle* fMWLinkPPCOptions;
  358.     // The following is split out from other compiler options because UMacAppUniversal.cp
  359.     // must be compiled to run on 68000 machines. The CPlus compiler does not have compiler
  360.     // directives to control machine options. It can only be controlled from the command
  361.     // line.
  362.     TStringHandle* fCPlusCPUOptions;
  363.     TStringHandle* fCPlusOptions;
  364.     TStringHandle* fSCOptions;
  365.     
  366.     TStringHandle* fPPCAsmOptions;
  367.     TStringHandle* fPPCCOptions;
  368.     TStringHandle* fMrCOptions;
  369.     TStringHandle* fPPCLibOptions;
  370.     TStringHandle* fPPCLinkOptions;
  371.     TStringHandle* fMakeSymOptions;
  372.  
  373.     TStringHandle* fRunTimeModel;
  374.     
  375.     TStringHandle* fMakeOptions;
  376.     TStringHandle* fRezOptions;
  377.     TStringHandle* fCreatorAndBundleOptions;
  378.  
  379.     TList* fTargStringList;
  380.     TStringHandle* fOptionFlags;
  381.  
  382.     FILE* fOutputFile;
  383.     FILE* fMakeFile;
  384.  
  385.     CStr255 fStartPath;
  386.  
  387.     TAssociation* fRenameFlagsPairs;
  388.     
  389.     CStr255 fXLinkMap;
  390.     CStr255 fXLinkXRef;
  391.     CStr255 fXUAppName_h;
  392.     CStr255 fXUAppName_cp;
  393.     CStr255 fXUAppName_cp_o;
  394.     CStr255 fXMAppName_cp;
  395.     CStr255 fXMAppName_cp_o;
  396.     CStr255 fXAppName_cp;
  397.     CStr255 fXAppName_cp_o;
  398.     
  399.     CStr255 fBuildFlags;
  400.  
  401.     CStr255 fAppPath;
  402.     CStr255 fAppName;
  403.     CStr255 fBuildFolderAppName;
  404.     CStr255 fIncApp;
  405.     CStr255 fSrcApp;
  406.     CStr255 fObjApp;
  407.     CStr255 fMAMakeFileExtension;
  408.     Boolean fAutomake;
  409.     Boolean fAutorez;
  410.     Boolean fAnyCPlus;
  411.     
  412.   public:
  413.     TMABuildTool();    // constructor
  414.     
  415.     virtual ~TMABuildTool();
  416.         // Destructor
  417.     
  418.     void IMABuildTool(int argc, char** argv);
  419.     
  420.     void GetRenameFlags();
  421.     
  422.     virtual void DoProcessFileArg(const CStr255& arg);    // override
  423.     
  424.     virtual void DoProcessOptionArg(short kw); // override
  425.     
  426.     virtual void DoShowUsage(); // override
  427.     
  428.     virtual void DoStartProgress(); // override
  429.     
  430.     virtual void DoToolAction(); // override
  431.     
  432.     virtual void InstallKeyWords(); // override
  433.  
  434.     void CatenateToSourceOptionStrings(const CStr255& newText);
  435.     
  436.     void Echo(const CStr255& aStr);
  437.     
  438.     void Execute(const CStr255& aStr);
  439.     
  440.     void SetIE(const CStr255& theVariable,
  441.                TStringHandle* theValue);
  442.     
  443.     void SetIE(const CStr255& theVariable,
  444.                const CStr255& theValue);
  445.     
  446.     void CreateFolder(const CStr255& name);
  447.     
  448.     Boolean Exists(const CStr255& theFile);
  449.  
  450.     void Failed(const CStr255& aStr);
  451.     
  452.     void CheckKeywords();
  453.  
  454.     void GetAutoBuild();
  455.     void AddAutoBuilds();
  456.     void AutoBuildTarget(const CStr255& autoBuildExtension);
  457.     void AddTargets(CStr255& targetNames);
  458.     
  459.     void DoOptionFlags_Part1();
  460.  
  461.     void DoOptionFlags_Part2();
  462.     
  463.     void OutputOptionFlags();
  464.  
  465.     void ParseTargetName(CStr255& targetName);
  466.     
  467. //    Boolean CheckSources(const CStr255& srcVar, const CStr255& srcFile,
  468. //                         const CStr255& objVar, const CStr255& objFile);
  469. //    
  470.     void CreateBuildFolder();
  471.     
  472.     void CreateObjectsFolder();
  473.     
  474.     void DoAllTargets();
  475.     
  476.     void DoATarget_Part1();
  477.     void DoATarget_Part2();
  478.     
  479.     void ExpandEnvironmentVars();
  480.     
  481.     void ExportEnvironmentVars();
  482.     
  483.     void CreateMakeFile();
  484.     void CatenateMake(const CStr255& fileName);
  485.     
  486.     void MakeTarget();
  487.     
  488.     void DoOverrides();
  489.     
  490.     void DoDefinitions();
  491.     
  492.     void DoDependencies();
  493.     
  494.     void SetMakeVariable(const CStr255& theVariable,
  495.                          TStringHandle* theValue);
  496.  
  497.     void SetMakeVariable(const CStr255& theVariable,
  498.                          const CStr255& theValue);
  499.     
  500.     void SetMakeVariable(const CStr255& theVariable,
  501.                          Boolean theValue);
  502.     
  503.     void SetMakeVariable(const CStr255& aString);
  504.  
  505.     void SetMakeIE(const CStr255& theVariable);
  506.         // Set a make variable to the same as the corresponding integrated
  507.         // environment variable. 
  508.     
  509.     void SetMakeIE(const CStr255& theVariable,
  510.                    const CStr255& theIEVariable);
  511.         // Set a make variable to the same as the corresponding integrated
  512.         // environment variable. 
  513.     
  514.     void OutputMakeVariables();
  515.  
  516.     void OutputTheEnd();
  517.     
  518.     void SetOutputFile(const CStr255& outputFileName);
  519. };
  520.  
  521.  
  522. TMABuildTool* gMABuildTool;        // The tool
  523. CStr255 gDirectorySeparator;    // : or / as required by host filesystem }
  524.  
  525. //========================================================================================
  526. // GLOBAL Procedures
  527. //========================================================================================
  528. #undef Inherited
  529.  
  530. static Boolean IEgetenv(const char* envName, CStr255& envValue);
  531. static void SubstituteInString(CStr255& s);
  532. static Boolean FindVariable(const CStr255& s, short& varBegin, short& varLength);
  533.  
  534. static void CatenateFile(FILE* fromFile, FILE* toFile);
  535. static void CatenateFile(const CStr255& fileName, FILE* toFile);
  536. static void PathNameFromDirID(long dirID, short vRefNum, CStr255& FullPathName);
  537.  
  538. //----------------------------------------------------------------------------------------
  539. // IEgetenv: 
  540. //----------------------------------------------------------------------------------------
  541. #pragma segment Main
  542.  
  543. // our own version to map to the Pascal routine with the same name
  544. Boolean IEgetenv(const char* envName, CStr255& envValue)
  545. {
  546.     envValue.Empty();    // initialize envValue
  547.     char * p = getenv(envName);    // try and get the variable
  548.     if (p != NULL)
  549.         envValue = p;        // copy value if it exists
  550.     return (p != NULL);
  551. }
  552.  
  553. //----------------------------------------------------------------------------------------
  554. // SubstituteInString: 
  555. //----------------------------------------------------------------------------------------
  556. #pragma segment ANonRes
  557.  
  558. void SubstituteInString(CStr255& s)
  559. {
  560.     short varBegin = 0;
  561.     short varLength;
  562.     while (FindVariable(s, varBegin, varLength))
  563.     {
  564.         CStr255 varName = s.Copy(varBegin + 1, varLength - 2);
  565.         CStr255 value;
  566.         if (IEgetenv(varName, value))
  567.         {
  568.             s.Delete(varBegin, varLength);
  569.             s.Insert(value, varBegin);
  570.             varBegin = 0;
  571.         }
  572.         else
  573.             varBegin += varLength - 1;    // skip unknown variable
  574.     }
  575. }
  576.  
  577. //----------------------------------------------------------------------------------------
  578. // FindVariable: 
  579. //----------------------------------------------------------------------------------------
  580. #pragma segment ANonRes
  581.  
  582. Boolean FindVariable(const CStr255& s, short& varBegin, short& varLength)
  583. {
  584.     // Returns the position and size of an embedded variable, including the {}
  585.     
  586.     Boolean found = FALSE;
  587.     varLength = 0;
  588.     short sLength = s.Length();
  589.     for (short i = varBegin + 1; i <= sLength; i++)
  590.     {
  591.         if (s[i] == '{')
  592.         {
  593.             varBegin = i;
  594.         }
  595.         else if ((varBegin > 0) && (s[i]  == '}'))
  596.         {
  597.             varLength = i - varBegin + 1;
  598.             found = TRUE;
  599.             break;
  600.         }
  601.     }
  602.     return found;
  603. }
  604.  
  605. //----------------------------------------------------------------------------------------
  606. // CatenateFile: 
  607. //----------------------------------------------------------------------------------------
  608. #pragma segment ANonRes
  609.  
  610. void CatenateFile(FILE* fromFile, FILE* toFile)
  611. {
  612.     char* buffer = (char*)malloc(BUFSIZ);
  613.     FailNIL(buffer);
  614.     while (!feof(fromFile))
  615.     {
  616.         size_t n = fread(buffer, 1, BUFSIZ, fromFile);
  617.         if (n > 0)
  618.             fwrite(buffer, 1, n, toFile);
  619.     }
  620.     free(buffer);
  621. }
  622.  
  623. //----------------------------------------------------------------------------------------
  624. // CatenateFile: 
  625. //----------------------------------------------------------------------------------------
  626. #pragma segment ANonRes
  627.  
  628. void CatenateFile(const CStr255& fileName, FILE* toFile)
  629. {
  630.     FILE* fromFile = fopen(fileName, "r");
  631.     CatenateFile(fromFile, toFile);
  632.     fclose(fromFile);
  633. }
  634.  
  635. //========================================================================================
  636. // CLASS TMABuildTool
  637. //========================================================================================
  638. #undef Inherited
  639. #define Inherited TCPlusTool
  640.  
  641. #pragma segment ANonRes
  642. MA_DEFINE_CLASS_M1(TMABuildTool, Inherited);
  643.  
  644. //----------------------------------------------------------------------------------------
  645. // TMABuildTool constructor
  646. //----------------------------------------------------------------------------------------
  647. #pragma segment TInit
  648.  
  649. TMABuildTool::TMABuildTool()
  650. {
  651.     // setup the default options
  652.     fGetBuildFlags = FALSE;
  653.     fGetFolderName = FALSE;
  654.     
  655.     fMacApp = TRUE;
  656.     fDebug = FALSE;
  657.     fInspector = FALSE;
  658.     fDebugMsg = FALSE;
  659.     fNames = FALSE;
  660.     fRangeCheck = FALSE;
  661.     fPerform = FALSE;
  662.     fSym = FALSE;
  663.     fSmallSym = FALSE;
  664.     fAlign = TRUE;
  665.     fAttachable = FALSE;
  666.     fSeparateObjects = TRUE;
  667.     // fSeparateObjectsFolder = "";
  668.     // fBuildFolder = "";
  669.     fMALibrary = TRUE;
  670.     fCPlusLoad = TRUE;
  671.     
  672.     fModelFar = FALSE;
  673. //CW added
  674.     fModelFarCode = FALSE;
  675.     fModelFarData = FALSE;
  676.         
  677.     fNeedsColorQD = TRUE;
  678.     fNeedsGX = FALSE;
  679.     fNeedsMC68020 = TRUE;
  680.     fNeedsMC68030 = FALSE;
  681.     fNeedsMC68040 = FALSE;
  682.     fPowerPC = FALSE;
  683.     fNeedsFPU = FALSE;
  684.     fNeedsSystem7 = TRUE;
  685.     fNeedsSystem7_5 = FALSE;
  686.  
  687.     fTemplateViews = TRUE;
  688.     fWriteTemplateViews = FALSE;
  689.     fAllProgress = FALSE;
  690.     fExecute = TRUE;
  691.     fAutoBuild = FALSE;
  692.     fUserAutoBuild = TRUE;
  693.     fNoFail = FALSE;
  694.     fFast = FALSE;
  695.     fLinkMap = FALSE;
  696.     fLinkXRef = FALSE;
  697.     fStatusOnly = FALSE;
  698.     fTimes = FALSE;
  699.     fRunAfterBuild = FALSE;
  700.     fSaveBeforeBuild = FALSE;
  701.     fExpandEnvironmentVars = FALSE;
  702.     fEverExported = FALSE;
  703.     fNeedsVU = FALSE;
  704.     fTheDebugger = FALSE;
  705.     
  706.     fCompiler = kwUnspecified;
  707.  
  708.     fClassic = FALSE;
  709.     fModelCFM = FALSE;
  710.     fRSRC = FALSE;
  711.     fFat = FALSE;
  712.     fRAMDisk = FALSE;
  713.     
  714.     fDrag = FALSE;
  715.     fGXPrinting = FALSE;
  716.     fGXViews = FALSE;
  717.     fPowerTalk = FALSE;
  718.         
  719.     fContainer = FALSE;
  720.     
  721.     fAsmOptions = NULL;
  722.     fEchoOptions = NULL;
  723.     fLibOptions = NULL;
  724.     fLinkOptions = NULL;
  725.  
  726.     fCOptions = NULL;
  727. //CW added
  728.     fMWC68KOptions = NULL;
  729.     fMWLink68KOptions = NULL;
  730.     fMWCPPCOptions = NULL;
  731.     fMWLinkPPCOptions = NULL;
  732.     
  733.     fCPlusCPUOptions = NULL;
  734.     fCPlusOptions = NULL;
  735.     fSCOptions = NULL;
  736.  
  737.     fPPCAsmOptions = NULL;
  738.     fPPCCOptions = NULL;
  739.     fMrCOptions = NULL;
  740.     fPPCLibOptions = NULL;
  741.     fPPCLinkOptions = NULL;
  742.     fMakeSymOptions = NULL;
  743.  
  744.     fRunTimeModel = NULL;
  745.     
  746.     fMakeOptions = NULL;
  747.     fRezOptions = NULL;
  748.     fCreatorAndBundleOptions = NULL;
  749.     fTargStringList = NULL;
  750.     fOptionFlags = NULL;
  751.     fOutputFile = NULL;
  752.     fMakeFile = NULL;
  753.     // fStartPath = "";
  754.     fRenameFlagsPairs = NULL;
  755. }
  756.  
  757. //----------------------------------------------------------------------------------------
  758. // TMABuildTool destructor
  759. //----------------------------------------------------------------------------------------
  760. #pragma segment MADestructorRes
  761.  
  762. TMABuildTool::~TMABuildTool()
  763. {
  764. }
  765.  
  766. //----------------------------------------------------------------------------------------
  767. // TMABuildTool::IMABuildTool: 
  768. //----------------------------------------------------------------------------------------
  769. #pragma segment TInit
  770.  
  771. void TMABuildTool::IMABuildTool(int argc, char** argv)
  772. {
  773.     TAssociation* anAssociation;
  774.     CStr255 aString;
  775.  
  776.     this->ICPlusTool(argc, argv);
  777.  
  778.     // Try to get the appropriate separator character for directories
  779.     if (IEgetenv("MADirectorySeparator", aString))
  780.         gDirectorySeparator = aString;
  781.     else
  782.         gDirectorySeparator = ":";
  783.  
  784.     fOutputFile = stdout;
  785.     
  786.     anAssociation = new TAssociation;
  787.     anAssociation->IAssociation();
  788.     fRenameFlagsPairs = anAssociation;
  789.  
  790.     fAsmOptions = NewTStringHandle();
  791.     fEchoOptions = NewTStringHandle();
  792.     fLibOptions = NewTStringHandle();
  793.     fLinkOptions = NewTStringHandle();
  794.     
  795.     fCOptions = NewTStringHandle();
  796. //CW added
  797.     fMWC68KOptions = NewTStringHandle();
  798.     fMWLink68KOptions = NewTStringHandle();
  799.     fMWCPPCOptions = NewTStringHandle();
  800.     fMWLinkPPCOptions = NewTStringHandle();
  801.  
  802.     fCPlusCPUOptions = NewTStringHandle();
  803.     fCPlusOptions = NewTStringHandle();
  804.     fSCOptions = NewTStringHandle();
  805.     fPPCAsmOptions = NewTStringHandle();
  806.     fPPCCOptions = NewTStringHandle();
  807.     fMrCOptions = NewTStringHandle();
  808.     fPPCLibOptions = NewTStringHandle();
  809.     fPPCLinkOptions = NewTStringHandle();
  810.     fMakeSymOptions = NewTStringHandle();
  811.  
  812.     fRunTimeModel = NewTStringHandle();
  813.     
  814.     fMakeOptions = NewTStringHandle();
  815.     fRezOptions = NewTStringHandle();
  816.     fCreatorAndBundleOptions = NewTStringHandle();
  817.  
  818.     fEchoOptions = NewTStringHandle();
  819.  
  820.     fTargStringList = NewList();
  821.  
  822.     fOptionFlags = NewTStringHandle();
  823.     
  824.     this->GetRenameFlags();
  825. }
  826.  
  827. //----------------------------------------------------------------------------------------
  828. // TMABuildTool::GetRenameFlags: 
  829. //----------------------------------------------------------------------------------------
  830. #pragma segment TInit
  831.  
  832. void TMABuildTool::GetRenameFlags()
  833. {
  834.     CStr255 uglyName;
  835.     CStr255 niceName;
  836.     
  837.     Handle renameFlags = Get1Resource('STR#', 1000);
  838.     if (renameFlags)
  839.     {
  840.         HLock(renameFlags);
  841.         short count = **(short **) renameFlags;
  842.         count >>= 1;    // divide by 2 to get number of pairs
  843.         StringPtr s = (StringPtr) (*renameFlags + sizeof(short));
  844.         while (--count >= 0)
  845.         {
  846.             uglyName = s;
  847.             s += *s + 1;
  848.             
  849.             niceName = s;
  850.             s += *s + 1;
  851.             
  852.             fRenameFlagsPairs->InsertEntry(uglyName, niceName);
  853.         }
  854.         HUnlock(renameFlags);
  855.         ReleaseResource(renameFlags);
  856.     }
  857. }
  858.  
  859. //----------------------------------------------------------------------------------------
  860. // TMABuildTool::DoShowUsage: 
  861. //----------------------------------------------------------------------------------------
  862. #pragma segment ANonRes
  863.  
  864. void TMABuildTool::DoShowUsage()
  865. {
  866.     CStr255 theHelpString;
  867.     short i;
  868.  
  869.     // output each string in the stringlist
  870.     i = 1;
  871.     GetIndString(theHelpString, kHelpStr, i);
  872.     while (theHelpString.Length() > 0)
  873.     {
  874.         fprintf(stdout, "%s\n", (const char *)theHelpString);
  875.         i++;
  876.         GetIndString(theHelpString, kHelpStr, i);
  877.     }
  878. }
  879.  
  880. //----------------------------------------------------------------------------------------
  881. // TMABuildTool::DoProcessFileArg: 
  882. //----------------------------------------------------------------------------------------
  883. #pragma segment TInit
  884.  
  885. void TMABuildTool::DoProcessFileArg(const CStr255& arg)
  886. {
  887.     // Special case for MacApp as target for backward compatibility (until post 2.0)
  888.     if (EqualString(arg, (StringPtr) "\pMacApp", FALSE, TRUE))
  889.     {
  890.         fAutoBuild = TRUE;
  891.     }
  892.     else
  893.     {
  894.         TStringHandle* aStringHandle = NewTStringHandle();
  895.         aStringHandle->Catenate(arg);
  896.         fTargStringList->InsertLast(aStringHandle);
  897.     }
  898. }
  899.  
  900. //----------------------------------------------------------------------------------------
  901. // TMABuildTool::DoStartProgress: 
  902. //----------------------------------------------------------------------------------------
  903. #pragma segment TInit
  904.  
  905. void TMABuildTool::DoStartProgress()
  906. {
  907.     // Don't show the copyright information if all we're getting is the folder name.
  908.     if (fProgress && !fGetFolderName)
  909.     {
  910.         CStr255 theDateTimeString;
  911.     
  912.         IUTimeString(fStartDateTime, TRUE, theDateTimeString);
  913.         fprintf(stdout, "# MABuildTool         Start: %s",
  914.                 (const char *)theDateTimeString);
  915.     
  916.         IUDateString(fStartDateTime, shortDate, theDateTimeString);
  917.         fprintf(stdout," %s\n",(const char *)theDateTimeString);
  918.         fprintf(stdout, "\n# %s\n\n", MA_COPYRIGHT);
  919.     }
  920. }
  921.  
  922. //----------------------------------------------------------------------------------------
  923. // TMABuildTool::CatenateToSourceOptionStrings: 
  924. //----------------------------------------------------------------------------------------
  925. #pragma segment ANonRes
  926.  
  927. void TMABuildTool::CatenateToSourceOptionStrings(const CStr255& newText)
  928. {
  929.     fAsmOptions->Catenate(newText);
  930.     fCOptions->Catenate(newText);
  931.  
  932.     fMWC68KOptions->Catenate(newText);
  933.     fMWCPPCOptions->Catenate(newText);
  934.     
  935.     fCPlusOptions->Catenate(newText);
  936.     fSCOptions->Catenate(newText);
  937.     fPPCAsmOptions->Catenate(newText);
  938.     fPPCCOptions->Catenate(newText);
  939.     fMrCOptions->Catenate(newText);
  940.     fRezOptions->Catenate(newText);
  941.     
  942.     //fMakeOptions->Catenate(newText);    // Don't include Make
  943. }
  944.  
  945. //----------------------------------------------------------------------------------------
  946. // TMABuildTool::DoProcessOptionArg: 
  947. //----------------------------------------------------------------------------------------
  948. #pragma segment TInit
  949.  
  950. void TMABuildTool::DoProcessOptionArg(short kw)
  951. {
  952.     CStr255 theNextArg;
  953.     
  954.     switch (kw)
  955.     {
  956.         // "    -Asm option…            # Pass through options to Assembler";
  957.         case kwAsm:
  958.             fAsmOptions->Catenate(" ");
  959.             this->GetNextArg(theNextArg);
  960.             fAsmOptions->Catenate(theNextArg);
  961.             break;
  962.  
  963.         // "    -BuildFolder…           # Specify root object folder for this build";
  964.         case kwBuildFolder:
  965.             this->GetNextArg(theNextArg);
  966.             fBuildFolder = theNextArg;
  967.             break;
  968.                 
  969.         // "    -BuildFlags             # Get the build flags for these options";
  970.         case kwBuildFlags:
  971.             fGetBuildFlags = TRUE;
  972.             break;
  973.                 
  974.         // "    -C option…              # Pass through options to C compiler";
  975.         case kwC:
  976.             fCOptions->Catenate(" ");
  977.             this->GetNextArg(theNextArg);
  978.             fCOptions->Catenate(theNextArg);
  979.             break;
  980.         
  981.         // "    -CP compiler            # Specify the C++ compiler to use:";
  982.         // "                            # MrC, MWC68K, MWCPPC, SCpp";
  983.         case kwCP:
  984.             this->GetNextArg(theNextArg);
  985.             {
  986.                 if (theNextArg[1] == '-')
  987.                 {
  988.                     SyntaxError("'" + theNextArg + "' < missing compiler name > ");
  989.                 }
  990.                 else
  991.                 {
  992.                     Boolean found = FALSE;
  993.                     short akw;
  994.                     if (LookupKeyword(theNextArg, akw))
  995.                     {
  996.                         if (akw == kwSymantec)
  997.                             akw = kwSCpp;
  998.                         
  999.                         if ((akw == kwMrC) || (akw == kwMWC68K) ||
  1000.                             (akw == kwMWCPPC) || (akw == kwSCpp))
  1001.                         {
  1002.                             fCompiler = akw;
  1003.                             found = TRUE;
  1004.                         }
  1005.                     }
  1006.                     
  1007.                     if (!found)
  1008.                         SyntaxError("'" + theNextArg + "' < not a compiler name > ");
  1009.                 }
  1010.             }
  1011.             break;
  1012.  
  1013.         // "    -CPlusPlus…             # Pass through generic C++ compiler options";
  1014.         case kwCPlusPlus:
  1015.             this->GetNextArg(theNextArg);
  1016.             
  1017.             fCPlusOptions->Catenate(" ");
  1018.             fCPlusOptions->Catenate(theNextArg);
  1019.             
  1020.             fSCOptions->Catenate(" ");
  1021.             fSCOptions->Catenate(theNextArg);
  1022.             
  1023.             fPPCCOptions->Catenate(" ");
  1024.             fPPCCOptions->Catenate(theNextArg);
  1025.             
  1026.             fMrCOptions->Catenate(" ");
  1027.             fMrCOptions->Catenate(theNextArg);
  1028.             break;
  1029.         
  1030.         // "    -CreatorAndBundle option… # Pass through options to CreatorAndBundle tool";
  1031.         case kwCreatorAndBundle:
  1032.             fCreatorAndBundleOptions->Catenate(" ");
  1033.             this->GetNextArg(theNextArg);
  1034.             fCreatorAndBundleOptions->Catenate(theNextArg);
  1035.             break;
  1036.  
  1037.         // "    -d name=(TRUE|FALSE)    # Set compile time variable name in all compilers";
  1038.         case kwd:
  1039.             this->GetNextArg(theNextArg);
  1040.             
  1041.             this->CatenateToSourceOptionStrings(" -d ");
  1042.             this->CatenateToSourceOptionStrings(theNextArg);
  1043.             break;
  1044.  
  1045.         // "    -E                      # Pass through -E to Make";
  1046.         case kwE:
  1047.             fMakeOptions->Catenate(" -e");
  1048.             break;
  1049.         
  1050.         // "    -Fat appname            # Build a fat binary by adding the code and resources";
  1051.         // "                            # from a 68K application file";
  1052.         case kwFat:
  1053.             fFat = TRUE;
  1054.             this->GetNextArg(fAppName68K);
  1055.             break;
  1056.  
  1057.         // "    -FolderName             # Get the folder name for these options";
  1058.         case kwFolderName:
  1059.             fGetFolderName = TRUE;
  1060.             break;
  1061.                 
  1062.         // "    -Help                   # Prints this list of options to stdout";
  1063.         
  1064.         // "    -Lib option…            # Pass through options to Librarian";
  1065.         case kwLib:
  1066.             fLibOptions->Catenate(" ");
  1067.             this->GetNextArg(theNextArg);
  1068.             fLibOptions->Catenate(theNextArg);
  1069.             break;
  1070.  
  1071.         // "    -Link option…           # Pass through options to Linker";
  1072.         case kwLink:
  1073.             fLinkOptions->Catenate(" ");
  1074.             this->GetNextArg(theNextArg);
  1075.             fLinkOptions->Catenate(theNextArg);
  1076.             break;
  1077.  
  1078.         // "    -Make option…           # Pass through options to Make";
  1079.         case kwMake:
  1080.             fMakeOptions->Catenate(" ");
  1081.             this->GetNextArg(theNextArg);
  1082.             fMakeOptions->Catenate(theNextArg);
  1083.             break;
  1084.  
  1085.         // "    -MakeSYM option…        # Pass through options to MakeSYM";
  1086.         case kwMakeSym:
  1087.             fMakeSymOptions->Catenate(" ");
  1088.             this->GetNextArg(theNextArg);
  1089.             fMakeSymOptions->Catenate(theNextArg);
  1090.             break;
  1091.  
  1092.         // "    -MrC option…            # Pass through options to Macintosh RISC C/C++ compiler";
  1093.         case kwMrC:
  1094.             fMrCOptions->Catenate(" ");
  1095.             this->GetNextArg(theNextArg);
  1096.             fMrCOptions->Catenate(theNextArg);
  1097.             break;
  1098.  
  1099.         // "    -MWC68K option…         # Pass through options to Metrowerks C/C++ 68K compiler";
  1100.         case kwMWC68K:
  1101.             fMWC68KOptions->Catenate(" ");
  1102.             this->GetNextArg(theNextArg);
  1103.             fMWC68KOptions->Catenate(theNextArg);
  1104.             break;
  1105.  
  1106.         // "    -MWLink68K option…         # Pass through options to Metrowerks C/C++ 68K linker";
  1107.         case kwMWLink68K:
  1108.             fMWLink68KOptions->Catenate(" ");
  1109.             this->GetNextArg(theNextArg);
  1110.             fMWLink68KOptions->Catenate(theNextArg);
  1111.             break;
  1112.  
  1113.         // "    -MWCPPC option…         # Pass through options to Metrowerks C/C++ PPC compiler";
  1114.         case kwMWCPPC:
  1115.             fMWCPPCOptions->Catenate(" ");
  1116.             this->GetNextArg(theNextArg);
  1117.             fMWCPPCOptions->Catenate(theNextArg);
  1118.             break;
  1119.  
  1120.         // "    -MWLinkPPC option…         # Pass through options to Metrowerks C/C++ PPC Linker";
  1121.         case kwMWLinkPPC:
  1122.             fMWLinkPPCOptions->Catenate(" ");
  1123.             this->GetNextArg(theNextArg);
  1124.             fMWLinkPPCOptions->Catenate(theNextArg);
  1125.             break;
  1126.  
  1127.         // "    -O outputFileName       # Specify where the mabuild results ought to go.
  1128.         case kwOutputFile:
  1129.             this->GetNextArg(theNextArg);
  1130.             this->SetOutputFile(theNextArg);
  1131.             break;
  1132.         
  1133.         // "    -PPCAsm option…         # Pass through options to PPC Assembler";
  1134.         case kwPPCAsm:
  1135.             fPPCAsmOptions->Catenate(" ");
  1136.             this->GetNextArg(theNextArg);
  1137.             fPPCAsmOptions->Catenate(theNextArg);
  1138.             break;
  1139.  
  1140.         // "    -PPCLib option…         # Pass through options to PPC Librarian";
  1141.         case kwPPCLib:
  1142.             fPPCLibOptions->Catenate(" ");
  1143.             this->GetNextArg(theNextArg);
  1144.             fPPCLibOptions->Catenate(theNextArg);
  1145.             break;
  1146.  
  1147.         // "    -PPCLink option…        # Pass through options to PPC Linker";
  1148.         case kwPPCLink:
  1149.             fPPCLinkOptions->Catenate(" ");
  1150.             this->GetNextArg(theNextArg);
  1151.             fPPCLinkOptions->Catenate(theNextArg);
  1152.             break;
  1153.  
  1154.         // "    -R                      # Pass through -R to Make and write results of Make to stdout";
  1155.         case kwR:
  1156.             fExecute = FALSE;
  1157.             fStatusOnly = TRUE;
  1158.             fMakeOptions->Catenate(" -r");
  1159.             break;
  1160.  
  1161.         // "    -RAMDisk name           # Use a RAM Disk for pre-compiled headers";
  1162.         case kwRAMDisk:
  1163.             fRAMDisk = TRUE;
  1164.             this->GetNextArg(fRAMDiskName);
  1165.             break;
  1166.  
  1167.         // "    -RenameFlag oldname newname # Rename separate object folders";
  1168.         case kwRenameFlag:
  1169.             {
  1170.                 CStr255 anotherArg;
  1171.                 
  1172.                 this->GetNextArg(theNextArg);
  1173.                 this->GetNextArg(anotherArg);
  1174.                 
  1175.                 fRenameFlagsPairs->InsertEntry(theNextArg, anotherArg);
  1176.             }
  1177.             break;
  1178.  
  1179.         // "    -Rez option…            # Pass through options to Resource compiler";
  1180.         case kwRez:
  1181.             fRezOptions->Catenate(" ");
  1182.             this->GetNextArg(theNextArg);
  1183.             fRezOptions->Catenate(theNextArg);
  1184.             break;
  1185.  
  1186.         // "    -RSRC                   # Build only an application .rsrc file";
  1187.         case kwRSRC:
  1188.             fRSRC = (kw == kwRSRC);
  1189.             break;
  1190.  
  1191.         // "    -S                      # Pass through -S to Make and write results of Make to stdout";
  1192.         case kwS:
  1193.             fExecute = FALSE;
  1194.             fStatusOnly = TRUE;
  1195.             fMakeOptions->Catenate(" -s");
  1196.             break;
  1197.  
  1198.         // "    -SCpp option…           # Pass through options to the Symantec C++ compiler";
  1199.         case kwSCpp:
  1200.             fSCOptions->Catenate(" ");
  1201.             this->GetNextArg(theNextArg);
  1202.             fSCOptions->Catenate(theNextArg);
  1203.             break;
  1204.  
  1205.         // "    -Symantec               # Equivalent to -CP SCpp (for compatibility)";
  1206.         case kwSymantec:
  1207.             fCompiler = kwSCpp;
  1208.             break;
  1209.  
  1210.         // "    -Version                # Display the tool version";
  1211.         case kwVersion:
  1212.             {
  1213.                 fprintf(stdout,"\n# MABuildTool - Release %s", MA_SHORT_VERSION);
  1214. #if qPowerPC
  1215.                 fprintf(stdout," - Power Macintosh version");
  1216. #else
  1217.                 fprintf(stdout," - 68K Macintosh version");
  1218. #endif
  1219.                 fprintf(stdout,"\n");
  1220.             }
  1221.             break;
  1222.  
  1223.         // "    -[No]Align              # Longword align all code and data for speed";
  1224.         case kwAlign:
  1225.         case kwNoAlign:
  1226.             fAlign = (kw == kwAlign);
  1227.             break;
  1228.             
  1229.         // "    -[No]Attachable         # Support for attaching scripts to objects";
  1230.         case kwAttachable:
  1231.         case kwNoAttachable:
  1232.             fAttachable = (kw == kwAttachable);
  1233.             break;
  1234.             
  1235.         // "    -[No]AutoBuild          # Auto-build the MacApp libraries (and any others)";
  1236.         case kwAutoBuild:
  1237.         case kwNoAutoBuild:
  1238.             fAutoBuild = (kw == kwAutoBuild);
  1239.             break;
  1240.  
  1241.         // "    -[No]Classic            # Build for classic 68K runtime";
  1242.         case kwClassic:
  1243.         case kwNoClassic:
  1244.             fClassic = (kw == kwClassic);
  1245.             if (fClassic)
  1246.                 fModelCFM = FALSE;
  1247.             break;
  1248.  
  1249.         // "    -[No]Container          # OpenDoc container application";
  1250.         case kwContainer:
  1251.         case kwNoContainer:
  1252.             fContainer = (kw == kwContainer);
  1253.             break;
  1254.  
  1255.         // "    -[No]CPlusLoad          # Make the C++ compiler use load/dump files";
  1256.         case kwCPlusLoad:
  1257.         case kwNoCPlusLoad:
  1258.             fCPlusLoad = (kw == kwCPlusLoad);
  1259.             break;
  1260.  
  1261.         // "    -[No]Debug              # Turn on debugging and install debugging gear";
  1262.         case kwDebug:
  1263.         case kwNoDebug:
  1264.             fPerform = fDebug = fDebugMsg  = fRangeCheck = fNames = (kw == kwDebug);
  1265.             
  1266.             // Default is to also turn on source debugging symbols,
  1267.             // but it can be turned off
  1268.             if (fDebug)
  1269.                 fSym = TRUE;
  1270.             break;
  1271.                 
  1272.         // "    -[No]DebugMsg           # Turn on extra debugging messages";
  1273.         case kwDebugMsg:
  1274.         case kwNoDebugMsg:
  1275.             fDebugMsg = (kw == kwDebugMsg);
  1276.             break;
  1277.  
  1278.         // "    -[No]Deluxe             # Include support for the coolest features";
  1279.         case kwDeluxe:
  1280.         case kwNoDeluxe:
  1281.             fAttachable = fDrag = fPowerTalk = (kw == kwDeluxe);
  1282.             break;
  1283.  
  1284.         // "    -[No]Drag               # Include support for Drag & Drop";
  1285.         case kwDrag:
  1286.         case kwNoDrag:
  1287.             fDrag = (kw == kwDrag);
  1288.             break;
  1289.  
  1290.         // "    -[No]Execute            # Execute the results of Make";
  1291.         case kwExecute:
  1292.         case kwNoExecute:
  1293.             fExecute = (kw == kwExecute);
  1294.             break;
  1295.             
  1296.         // "    -[No]ExpandEnvVars      # Expand environment vars in AppName.MakeIt";
  1297.         case kwExpandEnvVars:
  1298.         case kwNoExpandEnvVars:
  1299.             fExpandEnvironmentVars = (kw == kwExpandEnvVars);
  1300.             break;
  1301.  
  1302.         // "    -[No]Fail               # Stop executing after first failure";
  1303.         case kwNoFail:
  1304.         case kwFail:
  1305.             fNoFail = (kw == kwNoFail);
  1306.             break;
  1307.         
  1308.         // "    -[No]Fast               # Compile files in one batch (faster)";
  1309.         case kwNoFast:
  1310.         case kwFast:
  1311.             fFast = (kw == kwFast);
  1312.             break;
  1313.         
  1314.         // "    -[No]GXPrinting         # Include support for GX Printing";
  1315.         case kwGXPrinting:
  1316.         case kwNoGXPrinting:
  1317.             fGXPrinting = (kw == kwGXPrinting);
  1318.             break;
  1319.  
  1320.         // "    -[No]GXViews            # Include support for GX Views";
  1321.         case kwGXViews:
  1322.         case kwNoGXViews:
  1323.             fGXViews = (kw == kwGXViews);
  1324.             break;
  1325.  
  1326.         // "    -[No]Inspector          # Include hooks for the inspector";
  1327.         case kwInspector:
  1328.         case kwNoInspector:
  1329.             fInspector = (kw == kwInspector);
  1330.             break;
  1331.  
  1332.         // "    -[No]LinkMap            # Generate a link map in AppName.map";
  1333.         case kwLinkMap:
  1334.         case kwNoLinkMap:
  1335.             fLinkMap = (kw == kwLinkMap);
  1336.             break;
  1337.             
  1338.         // "    -[No]LinkXRef           # Generate a linker cross reference in AppName.xref";
  1339.         case kwLinkXRef:
  1340.         case kwNoLinkXRef:
  1341.             fLinkXRef = (kw == kwLinkXRef);
  1342.             break;
  1343.  
  1344.         // "    -[No]MacApp             # Build for use with MacApp";
  1345.         case kwMacApp:
  1346.         case kwNoMacApp:
  1347.             fMacApp = (kw == kwMacApp);
  1348.             break;
  1349.  
  1350.         // "    -[No]MALibrary          # Use library, not object files";
  1351.         case kwMALibrary:
  1352.         case kwNoMALibrary:
  1353.             fMALibrary = (kw == kwMALibrary);
  1354.             break;
  1355.  
  1356.         // "    -[No]ModelCFM           # Build for model CFM-68K support";
  1357.         case kwModelCFM:
  1358.         case kwNoModelCFM:
  1359.             fModelCFM = (kw == kwModelCFM);
  1360.             if (fModelCFM)
  1361.             {
  1362.                 fClassic = FALSE;
  1363.                 fModelFar = FALSE;
  1364. //CW added
  1365.                 fModelFarCode = FALSE;
  1366.                 fModelFarData = FALSE;
  1367.             }
  1368.             break;
  1369.  
  1370.         // "    -[No]ModelFar           # Build for model far support";
  1371.         case kwModelFar:
  1372.         case kwNoModelFar:
  1373.             fModelFar = (kw == kwModelFar);
  1374. //CW added
  1375.             fModelFarCode = (kw == kwModelFar);
  1376.             fModelFarData = (kw == kwModelFar);
  1377.             break;
  1378.                 
  1379. //CW added
  1380.         // "    -[No]ModelFarCode           # Build for model far code support";
  1381.         case kwModelFarCode:
  1382.         case kwNoModelFarCode:
  1383.             fModelFarCode = (kw == kwModelFarCode);
  1384.             break;
  1385.                 
  1386. //CW added
  1387.         // "    -[No]ModelFarData           # Build for model far data support";
  1388.         case kwModelFarData:
  1389.         case kwNoModelFarData:
  1390.             fModelFarData = (kw == kwModelFarData);
  1391.             break;
  1392.                 
  1393.         // "    -[No]Names              # Include embedded debugging symbols";
  1394.         case kwNames:
  1395.         case kwNoNames:
  1396.             fNames = (kw == kwNames);
  1397.             
  1398.             // Default is to also turn on source debugging symbols,
  1399.             // but it can be turned off
  1400.             if (fNames)
  1401.                 fSym = TRUE;
  1402.             break;
  1403.  
  1404.         // "    -[No]NeedsColorQD       # Build to require Color QuickDraw™";
  1405.         case kwNeedsColorQD:
  1406.         case kwNoNeedsColorQD:
  1407.             fNeedsColorQD = (kw == kwNeedsColorQD);
  1408.             break;
  1409.  
  1410.         // "    -[No]NeedsFPU           # Build to require a Floating point unit";
  1411.         case kwNeedsFPU:
  1412.         case kwNoNeedsFPU:
  1413.             fNeedsFPU = (kw == kwNeedsFPU);
  1414.             break;
  1415.  
  1416.         // "    -[No]NeedsGX           # Build to require GX";
  1417.         case kwNeedsGX:
  1418.         case kwNoNeedsGX:
  1419.             fNeedsGX = (kw == kwNeedsGX);
  1420.             break;
  1421.  
  1422.         // "    -[No]NeedsMC68020       # Build to require a 68020";
  1423.         case kwNeedsMC68020:
  1424.         case kwNoNeedsMC68020:
  1425.             fNeedsMC68020 = (kw == kwNeedsMC68020);
  1426.             if (fNeedsMC68020)
  1427.             {
  1428.                 fPowerPC = FALSE;
  1429.             }
  1430.             break;
  1431.  
  1432.         // "    -[No]NeedsMC68030       # Build to require a 68030";
  1433.         case kwNeedsMC68030:
  1434.         case kwNoNeedsMC68030:
  1435.             fNeedsMC68030 = (kw == kwNeedsMC68030);
  1436.             if (fNeedsMC68030)
  1437.             {
  1438.                 fPowerPC = FALSE;
  1439.             }
  1440.             break;
  1441.  
  1442.         // "    -[No]NeedsMC68040       # Build to require a 68040";
  1443.         case kwNeedsMC68040:
  1444.         case kwNoNeedsMC68040:
  1445.             fNeedsMC68040 = (kw == kwNeedsMC68040);
  1446.             if (fNeedsMC68040)
  1447.             {
  1448.                 fPowerPC = FALSE;
  1449.             }
  1450.             break;
  1451.  
  1452.         // "    -[No]NeedsSystem7       # Build to require System 7.0 or better";
  1453.         case kwNeedsSystem7:
  1454.         case kwNoNeedsSystem7:
  1455.             fNeedsSystem7 = (kw == kwNeedsSystem7);
  1456.             break;
  1457.  
  1458.         // "    -[No]NeedsSystem7       # Build to require System 7.0 or better";
  1459.         case kwNeedsSystem7_5:
  1460.         case kwNoNeedsSystem7_5:
  1461.             fNeedsSystem7_5 = (kw == kwNeedsSystem7_5);
  1462.             break;
  1463.  
  1464.         // "    -[No]NeedsVU            # Build for VU compatibility";
  1465.         case kwNeedsVU:
  1466.         case kwNoNeedsVU:
  1467.             fNeedsVU = (kw == kwNeedsVU);
  1468.             break;
  1469.  
  1470.         // "    -[No]P                  # Show progress for the MABuild system";
  1471.         
  1472.         // "    -[No]Perform            # Include performance monitor code";
  1473.         case kwPerform:
  1474.         case kwNoPerform:
  1475.             fPerform = (kw == kwPerform);
  1476.             break;
  1477.  
  1478.         // "    -[No]PowerTalk          # Include support for PowerTalk Mailers";
  1479.         case kwPowerTalk:
  1480.         case kwNoPowerTalk:
  1481.             fPowerTalk = (kw == kwPowerTalk);
  1482.             break;
  1483.  
  1484.         // "    -[No]PP                 # Have all invoked tools show progress too";
  1485.         case kwPP:
  1486.         case kwNoPP:
  1487.             fAllProgress = fProgress = (kw == kwPP);
  1488.             break;
  1489.  
  1490.         // "    -[No]RangeCheck         # Force range/overflow checking";
  1491.         case kwRangeCheck:
  1492.         case kwNoRangeCheck:
  1493.             fRangeCheck = (kw == kwRangeCheck);
  1494.             break;
  1495.  
  1496.         // "    -[No]Run                # Run after build";
  1497.         case kwRun:
  1498.         case kwNoRun:
  1499.             fRunAfterBuild = (kw == kwRun);
  1500.             break;
  1501.  
  1502.         // "    -[No]Save               # Auto-save all open windows before starting build";
  1503.         case kwSave:
  1504.         case kwNoSave:
  1505.             fSaveBeforeBuild = (kw == kwSave);
  1506.             break;
  1507.  
  1508.         // "    -[No]SeparateObjects    # Keep separate object folders for each build variation";
  1509.         case kwSeparateObjects:
  1510.         case kwNoSeparateObjects:
  1511.             fSeparateObjects = (kw == kwSeparateObjects);
  1512.             break;
  1513.  
  1514.         // "    -[No]SmallSym           # Try to generate smaller symbol files (slow!)";
  1515.         case kwSmallSym:
  1516.         case kwNoSmallSym:
  1517.             fSmallSym = (kw == kwSmallSym);
  1518.             fSym = TRUE;
  1519.             break;
  1520.             
  1521.         // "    -[No]StatusOnly         # Write results of Make to stdout";
  1522.         case kwStatusOnly:
  1523.         case kwNoStatusOnly:
  1524.             fExecute = (kw == kwNoStatusOnly);
  1525.             fStatusOnly = (kw == kwStatusOnly);
  1526.             break;
  1527.  
  1528.         // "    -[No]Sym                # Generate SADE-compatible symbol information";
  1529.         case kwSym:
  1530.         case kwNoSym:
  1531.             fSym = (kw == kwSym);
  1532.             if (!fSym)
  1533.                 fSmallSym = FALSE;
  1534.             break;
  1535.         
  1536.         // "    -[No]T                  # Show elapsed time for the MABuild system";
  1537.         
  1538.         // "    -[No]TemplateViews      # Include code to create views from templates";
  1539.         case kwTemplateViews:
  1540.         case kwNoTemplateViews:
  1541.             fTemplateViews = (kw == kwTemplateViews);
  1542.             break;
  1543.  
  1544.         // "    -[No]TT                 # Have all invoked tools show elapsed time too";
  1545.         case kwTT:
  1546.         case kwNoTT:
  1547.             fTimes = fTime = (kw == kwTT);
  1548.             break;
  1549.  
  1550.         // "    -[No]UserAutoBuild      # Auto-build user-specified libraries {MAUserAutoBuild}";
  1551.         case kwUserAutoBuild:
  1552.         case kwNoUserAutoBuild:
  1553.             fUserAutoBuild= (kw == kwUserAutoBuild);
  1554.             break;
  1555.  
  1556.         // "    -[No]WriteTemplateViews # Include code to write view resources"
  1557.         case kwWriteTemplateViews:
  1558.         case kwNoWriteTemplateViews:
  1559.             fWriteTemplateViews = (kw == kwWriteTemplateViews);
  1560.             break;
  1561.  
  1562.         case kwTheDebugger:
  1563.         case kwNoTheDebugger:
  1564.             fTheDebugger = (kw == kwTheDebugger);
  1565.             break;
  1566.         
  1567.         default:
  1568.             Inherited::DoProcessOptionArg(kw);
  1569.             break;
  1570.     }
  1571. }
  1572.  
  1573. //----------------------------------------------------------------------------------------
  1574. // TMABuildTool::InstallKeyWords: 
  1575. //----------------------------------------------------------------------------------------
  1576. #pragma segment TInit
  1577.  
  1578. void TMABuildTool::InstallKeyWords()
  1579. {
  1580.     KeyWordStruct keywords [] =
  1581.     {
  1582.         {"Asm", kwAsm},
  1583.         {"BuildFlags", kwBuildFlags},
  1584.         {"BuildFolder", kwBuildFolder},
  1585.         {"C", kwC},
  1586.         {"CP", kwCP},
  1587.         {"CPlusPlus", kwCPlusPlus},
  1588.         {"CreatorAndBundle", kwCreatorAndBundle},
  1589.         {"d", kwd},
  1590.         {"E", kwE},
  1591.         {"Fat", kwFat},
  1592.         {"FolderName", kwFolderName},
  1593.         {"Lib", kwLib},
  1594.         {"Link", kwLink},
  1595.         {"Make", kwMake},
  1596.         {"MakeSym", kwMakeSym},
  1597.         {"MrC", kwMrC},
  1598.         {"MWC68K", kwMWC68K},
  1599.         {"MWCPPC", kwMWCPPC},
  1600.  
  1601.         {"MWLink68K", kwMWLink68K},
  1602.         {"MWLinkPPC", kwMWLinkPPC},
  1603.  
  1604.         {"O", kwOutputFile},
  1605.                 
  1606.         {"PPCAsm", kwPPCAsm},
  1607.         {"PPCLib", kwPPCLib},
  1608.         {"PPCLink", kwPPCLink},
  1609.         {"R", kwR},
  1610.         {"RAMDisk", kwRAMDisk},
  1611.         {"RenameFlag", kwRenameFlag},
  1612.         {"Rez", kwRez},
  1613.         {"RSRC", kwRSRC},
  1614.         {"S", kwS},
  1615.         {"SCpp", kwSCpp},
  1616.         {"Symantec", kwSymantec},
  1617.         {"Version", kwVersion},
  1618.  
  1619.         {"Align", kwAlign},                        {"NoAlign", kwNoAlign},
  1620.         {"Attachable", kwAttachable},            {"NoAttachable", kwNoAttachable},
  1621.         {"AutoBuild", kwAutoBuild},                {"NoAutoBuild", kwNoAutoBuild},
  1622.         {"Classic", kwClassic},                    {"NoClassic", kwNoClassic},
  1623.         {"Container", kwContainer},                {"NoContainer", kwNoContainer},
  1624.         {"CPlusLoad", kwCPlusLoad},                {"NoCPlusLoad", kwNoCPlusLoad},
  1625.         {"Debug", kwDebug},                        {"NoDebug", kwNoDebug},
  1626.         {"DebugMsg", kwDebugMsg},                {"NoDebugMsg", kwNoDebugMsg},
  1627.         {"Deluxe", kwDeluxe},                    {"NoDeluxe", kwNoDeluxe},
  1628.         {"Drag", kwDrag},                        {"NoDrag", kwNoDrag},
  1629.         {"Execute", kwExecute},                    {"NoExecute", kwNoExecute},
  1630.         {"ExpandEnvVars", kwExpandEnvVars},        {"NoExpandEnvVars", kwNoExpandEnvVars},
  1631.         {"Fail", kwFail},                        {"NoFail", kwNoFail},
  1632.         {"Fast", kwFast},                        {"NoFast", kwNoFast},
  1633.         {"GXPrinting", kwGXPrinting},            {"NoGXPrinting", kwNoGXPrinting},
  1634.         {"GXViews", kwGXViews},                    {"NoGXViews", kwNoGXViews},
  1635.         {"Inspector", kwInspector},                {"NoInspector", kwNoInspector},
  1636.         {"LinkMap", kwLinkMap},                    {"NoLinkMap", kwNoLinkMap},
  1637.         {"LinkXRef", kwLinkXRef},                {"NoLinkXRef", kwNoLinkXRef},
  1638.         {"MacApp", kwMacApp},                    {"NoMacApp", kwNoMacApp},
  1639.         {"MALibrary", kwMALibrary},                {"NoMALibrary", kwNoMALibrary},
  1640.         {"ModelCFM", kwModelCFM},                {"NoModelCFM", kwNoModelCFM},
  1641.         {"ModelFar", kwModelFar},                {"NoModelFar", kwNoModelFar},
  1642.  
  1643.         {"ModelFarCode", kwModelFarCode},        {"NoModelFarCode", kwNoModelFarCode},
  1644.         {"ModelFarData", kwModelFarData},        {"NoModelFarData", kwNoModelFarData},
  1645.  
  1646.         {"Names", kwNames},                        {"NoNames", kwNoNames},
  1647.         {"NeedsColorQD", kwNeedsColorQD},        {"NoNeedsColorQD", kwNoNeedsColorQD},
  1648.         {"NeedsFPU", kwNeedsFPU},                {"NoNeedsFPU", kwNoNeedsFPU},
  1649.         {"NeedsGX", kwNeedsGX},                    {"NoNeedsGX", kwNoNeedsGX},
  1650.         {"NeedsMC68020", kwNeedsMC68020},        {"NoNeedsMC68020", kwNoNeedsMC68020},
  1651.         {"NeedsMC68030", kwNeedsMC68030},        {"NoNeedsMC68030", kwNoNeedsMC68030},
  1652.         {"NeedsMC68040", kwNeedsMC68040},        {"NoNeedsMC68040", kwNoNeedsMC68040},
  1653.         {"NeedsSystem7", kwNeedsSystem7},        {"NoNeedsSystem7", kwNoNeedsSystem7},
  1654.         {"NeedsSystem7_5", kwNeedsSystem7_5},    {"NoNeedsSystem7_5", kwNoNeedsSystem7_5},
  1655.         {"NeedsVU", kwNeedsVU},                    {"NoNeedsVU", kwNoNeedsVU},
  1656.         {"Perform", kwPerform},                    {"NoPerform", kwNoPerform},
  1657.         {"PowerTalk", kwPowerTalk},                {"NoPowerTalk", kwNoPowerTalk},
  1658.         {"PP", kwPP},                            {"NoPP", kwNoPP},
  1659.         {"RangeCheck", kwRangeCheck},            {"NoRangeCheck", kwNoRangeCheck},
  1660.         {"Run", kwRun},                            {"NoRun", kwNoRun},
  1661.         {"Save", kwSave},                        {"NoSave", kwNoSave},
  1662.         {"SeparateObjects", kwSeparateObjects},    {"NoSeparateObjects", kwNoSeparateObjects},
  1663.         {"SmallSym", kwSmallSym},                {"NoSmallSym", kwNoSmallSym},
  1664.         {"StatusOnly", kwStatusOnly},            {"NoStatusOnly", kwNoStatusOnly},
  1665.         {"Sym", kwSym},                            {"NoSym", kwNoSym},
  1666.         {"TemplateViews", kwTemplateViews},        {"NoTemplateViews", kwNoTemplateViews},
  1667.         {"TheDebugger", kwTheDebugger},            {"NoTheDebugger", kwNoTheDebugger},
  1668.         {"TT", kwTT},                            {"NoTT", kwNoTT},
  1669.         {"UserAutoBuild", kwUserAutoBuild},        {"NoUserAutoBuild", kwNoUserAutoBuild},
  1670.         {"WriteTemplateViews", kwWriteTemplateViews},    {"NoWriteTemplateViews", kwNoWriteTemplateViews}
  1671.     };
  1672.     
  1673.     Inherited::InstallKeyWords();
  1674.     
  1675.     for (short i = 0; i < sizeof(keywords) / sizeof(KeyWordStruct); i++)
  1676.         this->InstallKeyWord(keywords[i].keyword, keywords[i].keyvalue);
  1677. }
  1678.  
  1679. //----------------------------------------------------------------------------------------
  1680. // TMABuildTool::Execute: 
  1681. //----------------------------------------------------------------------------------------
  1682. #pragma segment ANonRes
  1683.  
  1684. void TMABuildTool::Execute(const CStr255& aStr)
  1685. {
  1686.     fprintf(fOutputFile,"%s\n", (const char *)aStr);
  1687. }
  1688.  
  1689. //----------------------------------------------------------------------------------------
  1690. // TMABuildTool::SetIE: 
  1691. //----------------------------------------------------------------------------------------
  1692. #pragma segment ANonRes
  1693.  
  1694. void TMABuildTool::SetIE(const CStr255& theVariable,
  1695.                          TStringHandle* theValue)
  1696. {
  1697.     fprintf(fOutputFile, "SET %s \"", (const char *)theVariable);
  1698.     theValue->WriteToFile(fOutputFile);
  1699.     fprintf(fOutputFile, "\"\n");
  1700. }
  1701.  
  1702. //----------------------------------------------------------------------------------------
  1703. // TMABuildTool::SetIE: 
  1704. //----------------------------------------------------------------------------------------
  1705. #pragma segment ANonRes
  1706.  
  1707. void TMABuildTool::SetIE(const CStr255& theVariable,
  1708.                          const CStr255& theValue)
  1709. {
  1710.     fprintf(fOutputFile, "SET %s \"%s\"\n", (const char *)theVariable, (const char *)theValue);
  1711. }
  1712.  
  1713. //----------------------------------------------------------------------------------------
  1714. // TMABuildTool::Echo: 
  1715. //----------------------------------------------------------------------------------------
  1716. #pragma segment ANonRes
  1717.  
  1718. void TMABuildTool::Echo(const CStr255& aStr)
  1719. {
  1720.     fprintf(fOutputFile,"{MAEcho} %s\n",(const char *)aStr);
  1721. }
  1722.  
  1723. //----------------------------------------------------------------------------------------
  1724. // TMABuildTool::CreateFolder: 
  1725. //----------------------------------------------------------------------------------------
  1726. #pragma segment ANonRes
  1727.  
  1728. void TMABuildTool::CreateFolder(const CStr255& name)
  1729. {
  1730.     if ((name.Length() > 0) && !Exists(name))
  1731.     {
  1732.         long dirID;
  1733.         if (DirCreate(0, 0, name, &dirID) != noErr)
  1734.         {
  1735.             this->Failed("Unable to create folder: " + name);
  1736.         }
  1737.     }
  1738. }
  1739.  
  1740. //----------------------------------------------------------------------------------------
  1741. // TMABuildTool::Exists: 
  1742. //----------------------------------------------------------------------------------------
  1743. #pragma segment ANonRes
  1744.  
  1745. Boolean TMABuildTool::Exists(const CStr255& theFile)
  1746. {
  1747.     CStr255 fileName = theFile;
  1748.     
  1749.     // Return true if the file or directory exists
  1750.     CInfoPBRec aCInfoPBRec;
  1751.  
  1752.     aCInfoPBRec.hFileInfo.ioCompletion = NULL;
  1753.     aCInfoPBRec.hFileInfo.ioNamePtr = (StringPtr)&fileName;
  1754.     aCInfoPBRec.hFileInfo.ioVRefNum = 0;
  1755.     aCInfoPBRec.hFileInfo.ioFRefNum = 0;
  1756.     aCInfoPBRec.hFileInfo.ioFDirIndex = 0;
  1757.     aCInfoPBRec.hFileInfo.ioDirID = 0;
  1758.  
  1759.     return (PBGetCatInfoSync(&aCInfoPBRec) == noErr) && (aCInfoPBRec.hFileInfo.ioResult == noErr);
  1760. }
  1761.  
  1762. //----------------------------------------------------------------------------------------
  1763. // TMABuildTool::Failed: 
  1764. //----------------------------------------------------------------------------------------
  1765. #pragma segment ANonRes
  1766.  
  1767. void TMABuildTool::Failed(const CStr255& aStr)
  1768. {
  1769.     this->Echo("MABuild: " + aStr);
  1770.     this->Echo("MABuild of {XAppName} failed: `DATE`");
  1771.     this->Execute("{MAFailed}");
  1772.  
  1773.     if (fNoFail)
  1774.         this->SetIE("XRunStatus", "1");
  1775.     else
  1776.         this->Execute("EXIT 1");
  1777. }
  1778.  
  1779. //----------------------------------------------------------------------------------------
  1780. // PathNameFromDirID: 
  1781. //----------------------------------------------------------------------------------------
  1782. #pragma segment ANonRes
  1783.  
  1784. void PathNameFromDirID(long dirID, short vRefNum, CStr255& FullPathName)
  1785. {
  1786.     const short fsRtDir = 2;
  1787.     CInfoPBRec Block;
  1788.     CStr255 directoryName;
  1789.     OSErr err;
  1790.  
  1791.     FullPathName.Empty();
  1792.     Block.hFileInfo.ioNamePtr = (StringPtr)&directoryName;
  1793.     Block.dirInfo.ioDrParID = dirID;
  1794.  
  1795.     do
  1796.     {
  1797.         Block.hFileInfo.ioVRefNum = vRefNum;
  1798.         Block.hFileInfo.ioFDirIndex = - 1;
  1799.         Block.dirInfo.ioDrDirID = Block.dirInfo.ioDrParID;
  1800.         err = PBGetCatInfoSync(&Block);
  1801.     
  1802.         directoryName = directoryName + ":";
  1803.         
  1804.         FullPathName = directoryName + FullPathName;
  1805.     } while (Block.dirInfo.ioDrDirID != fsRtDir);
  1806. }
  1807.  
  1808. //----------------------------------------------------------------------------------------
  1809. // TMABuildTool::CheckKeywords: 
  1810. //----------------------------------------------------------------------------------------
  1811. #pragma segment ANonRes
  1812.  
  1813. void TMABuildTool::CheckKeywords()
  1814. {
  1815.     // Resolve matrix of options.
  1816.     
  1817.     if (fNeedsSystem7_5)
  1818.         fNeedsSystem7 = TRUE;
  1819.  
  1820.     if (fNeedsGX)
  1821.     {
  1822.         fGXPrinting = TRUE;
  1823.         fGXViews = TRUE;
  1824.     }
  1825.  
  1826.     if (fModelCFM)
  1827.     {
  1828.         if (fCompiler == kwUnspecified)
  1829.             fCompiler = kwSCpp;
  1830.         
  1831.         fModelFar = FALSE;
  1832.  
  1833.         fModelFarCode = FALSE;
  1834.         fModelFarData = FALSE;
  1835.  
  1836.         fNeedsMC68030 = TRUE;
  1837.         fPowerPC = FALSE;
  1838.         fNeedsSystem7 = TRUE;
  1839.     }
  1840.     
  1841.     if (fClassic)
  1842.     {
  1843.         if (fCompiler == kwUnspecified)
  1844.             fCompiler = kwSCpp;
  1845.         fPowerPC = FALSE;
  1846.     }
  1847.     
  1848.     // Default the compiler if none specified
  1849.     
  1850.     if (fCompiler == kwUnspecified)
  1851.     {
  1852.         if (fPowerPC)
  1853.             fCompiler = kwMrC;
  1854.         else
  1855.         {
  1856.             fCompiler = kwSCpp;
  1857.             if (!fModelCFM)
  1858.                 fClassic = TRUE;
  1859.         }
  1860.     }
  1861.     
  1862.     // Force other options that are dependent on the compiler
  1863.     
  1864.     if ((fCompiler == kwMrC) || (fCompiler == kwMWCPPC))
  1865.     {
  1866.         fNames = FALSE;
  1867.         fPerform = FALSE;
  1868.         fModelFar = FALSE;
  1869.  
  1870.         fModelFarCode = FALSE;
  1871.         fModelFarData = FALSE;
  1872.  
  1873.         fNeedsColorQD = TRUE;
  1874.         fNeedsMC68020 = FALSE;
  1875.         fNeedsMC68030 = FALSE;
  1876.         fNeedsMC68040 = FALSE;
  1877.         fPowerPC = TRUE;
  1878.         fNeedsFPU = TRUE;
  1879.         fNeedsSystem7 = TRUE;
  1880.     }
  1881.     
  1882.     if (fCompiler == kwMWC68K)
  1883.         fPerform = FALSE;
  1884.  
  1885.     if ((fCompiler == kwSCpp) || (fCompiler == kwMWC68K))
  1886.         fPowerPC = FALSE;
  1887.  
  1888.     if ((fCompiler != kwMWCPPC) && (fCompiler != kwMWC68K))
  1889.         fFast = FALSE;
  1890.  
  1891.     if (!fProgress)
  1892.         fEchoOptions->Catenate(" ∑ Dev:NULL ");
  1893.     
  1894.     if (!fPowerPC)
  1895.     {
  1896.         if (fDebug)
  1897.             fNames = TRUE;
  1898.     }
  1899. }
  1900.  
  1901. //----------------------------------------------------------------------------------------
  1902. // TMABuildTool::GetAutoBuild: 
  1903. //----------------------------------------------------------------------------------------
  1904. #pragma segment ANonRes
  1905.  
  1906. void TMABuildTool::GetAutoBuild()
  1907. {
  1908.     if (fUserAutoBuild)
  1909.     {
  1910.         CStr255 MAUserAutoBuild;
  1911.         if (IEgetenv("MAUserAutoBuild", MAUserAutoBuild) && !MAUserAutoBuild.IsEmpty())
  1912.             this->AddTargets(MAUserAutoBuild);
  1913.     }
  1914.  
  1915.     if (fAutoBuild)
  1916.     {
  1917.         CStr255 targetNames;
  1918.         Boolean defined;
  1919.         if (fPowerPC)
  1920.             defined = IEgetenv("MAAutoBuildPowerPC", targetNames);
  1921.         else
  1922.             defined = IEgetenv("MAAutoBuild", targetNames);
  1923.         
  1924.         if (defined && !targetNames.IsEmpty())
  1925.             this->AddTargets(targetNames);
  1926.         
  1927.         this->AddAutoBuilds();
  1928.     }
  1929. }
  1930.  
  1931. //----------------------------------------------------------------------------------------
  1932. // TMABuildTool::AddAutoBuilds: 
  1933. //----------------------------------------------------------------------------------------
  1934. #pragma segment ANonRes
  1935.  
  1936. void TMABuildTool::AddAutoBuilds()
  1937. {
  1938.     CStr255 autoBuildExtension;
  1939.     if (IEgetenv("MAAutoBuildExtension", autoBuildExtension))
  1940.     {
  1941.         // Loop through the targets and get their autobuild requirements. 
  1942.         // The autobuild targets are added to the front of the list. 
  1943.         // Because we're using an iterator, the current index will be
  1944.         // adjusted when we insert new targets. However, we will not process
  1945.         // autobuild targets recursively, because the iterator also adjusts
  1946.         // the low bound when we insert. 
  1947.         
  1948.         TStringHandle* stringHandle;
  1949.         CObjectIterator iter(fTargStringList, kIterateBackward);
  1950.         for (stringHandle = (TStringHandle*) iter.FirstObject(); iter.More(); stringHandle = (TStringHandle*) iter.NextObject())
  1951.         {
  1952.             this->ParseTargetName(stringHandle->AsStr255());
  1953.             this->AutoBuildTarget(autoBuildExtension);
  1954.         }
  1955.     }
  1956. }
  1957.  
  1958. //----------------------------------------------------------------------------------------
  1959. // TMABuildTool::AutoBuildTarget: 
  1960. //----------------------------------------------------------------------------------------
  1961. #pragma segment ANonRes
  1962.  
  1963. void TMABuildTool::AutoBuildTarget(const CStr255& autoBuildExtension)
  1964. {
  1965.     // Look for a target.autobuild file
  1966.     CStr255 autobuild(fAppPath + fAppName + autoBuildExtension);
  1967.     if (Exists(autobuild))
  1968.     {
  1969.         FILE* autobuildFile = fopen(autobuild, "r");
  1970.         if (autobuildFile)
  1971.         {
  1972.             char targetNames[256];
  1973.             while (fgets(targetNames, 255, autobuildFile))
  1974.             {
  1975.                 short l = strlen(targetNames) - 1;
  1976.                 if ((l > 0) && (targetNames[l] == '\n') || (targetNames[l] == '\r'))
  1977.                     targetNames[l] = 0;
  1978.                 
  1979.                 this->AddTargets(CStr255(targetNames));
  1980.             }
  1981.             fclose(autobuildFile);
  1982.         }
  1983.     }
  1984. }
  1985.  
  1986. //----------------------------------------------------------------------------------------
  1987. // TMABuildTool::AddTargets: 
  1988. //----------------------------------------------------------------------------------------
  1989. #pragma segment ANonRes
  1990.  
  1991. void TMABuildTool::AddTargets(CStr255& targetNames)
  1992. {
  1993.     while (targetNames.Length() > 0)
  1994.     {
  1995.         short i = targetNames.Pos(",");
  1996.         if (i == 0)
  1997.             i = targetNames.Length();
  1998.         else
  1999.             i = i - 1;
  2000.         
  2001.         TStringHandle* stringHandle = NewTStringHandle();
  2002.         stringHandle->Catenate(targetNames.Copy(1, i));
  2003.         fTargStringList->InsertFirst(stringHandle);
  2004.         targetNames.Delete(1, (short)Min(i + 1, targetNames.Length())); // toss the target & ,
  2005.     }
  2006. }
  2007.  
  2008. //----------------------------------------------------------------------------------------
  2009. // TMABuildTool::DoOptionFlags_Part1: 
  2010. //----------------------------------------------------------------------------------------
  2011. #pragma segment ANonRes
  2012.  
  2013. void TMABuildTool::DoOptionFlags_Part1(void)
  2014. {
  2015.     if (fRSRC || fPowerPC)
  2016.     {
  2017.         // Using MetroWerks or Symantec, so define a variable stating this.  This will only be used in strategic places in some
  2018.         // resources where CODE's are included.  Since we don't want this, we'll condition them with #ifdef qNoCode.
  2019.         
  2020.         //this->CatenateToSourceOptionStrings(" -d qNoCode=TRUE");
  2021.         fRezOptions->Catenate(" -d qNoCode=TRUE");
  2022.     }
  2023.     else
  2024.         fRezOptions->Catenate(" -d qNoCode=FALSE");
  2025.  
  2026.     // Building for use with MacApp?
  2027.     if (fMacApp)
  2028.         this->CatenateToSourceOptionStrings(" -d qMacApp=TRUE");
  2029.     else
  2030.         this->CatenateToSourceOptionStrings(" -d qMacApp=FALSE");
  2031.  
  2032.     if (fAlign)
  2033.     {
  2034.         fLinkOptions->Catenate(" -ac 4 -ad 4");
  2035.         fRezOptions->Catenate(" -align longword");
  2036.     }
  2037.  
  2038.     // process elapsed time indication
  2039.     if (fTimes)
  2040.     {
  2041.         CStr255 aString(" -t");
  2042.         
  2043.         fAsmOptions->Catenate(aString);
  2044.         fCreatorAndBundleOptions->Catenate(aString);
  2045.         fCOptions->Catenate(aString);
  2046.         fCPlusOptions->Catenate(aString);
  2047.         fPPCAsmOptions->Catenate(aString);
  2048.     }
  2049.  
  2050.     // Progress indication
  2051.     if (fAllProgress)
  2052.     {
  2053.         CStr255 aString(" -p");
  2054.         
  2055.         this->CatenateToSourceOptionStrings(aString);
  2056.         fLibOptions->Catenate(aString);
  2057.         fLinkOptions->Catenate(aString);
  2058. //CW added
  2059.         fMWC68KOptions->Catenate(aString);
  2060.         fMWLink68KOptions->Catenate(aString);
  2061.         fMWCPPCOptions->Catenate(aString);
  2062.         fMWLinkPPCOptions->Catenate(aString);
  2063.  
  2064.         fCreatorAndBundleOptions->Catenate(aString);
  2065.         fPPCLibOptions->Catenate(aString);
  2066.         fPPCLinkOptions->Catenate(aString);
  2067.         fMakeSymOptions->Catenate(aString);
  2068.     }
  2069.  
  2070.     if (fPowerPC)
  2071.     {
  2072.         // PreSystem 7.5 support
  2073.         if (fNeedsSystem7_5)
  2074.         {
  2075.             fOptionFlags->Catenate("75");
  2076.             this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=TRUE -d SystemSevenFiveOrLater=TRUE");
  2077.         }
  2078.         else
  2079.             this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=FALSE -d SystemSevenFiveOrLater=FALSE");
  2080.     
  2081.         // System 7.0, ColorQD support is always on, FPU is always off
  2082.         if (!fNeedsSystem7_5)
  2083.             fOptionFlags->Catenate("S7");
  2084.         this->CatenateToSourceOptionStrings(" -d qNeedsAppleEventMgr=TRUE");
  2085.         this->CatenateToSourceOptionStrings(" -d qNeedsEditionMgr=TRUE");
  2086.         this->CatenateToSourceOptionStrings(" -d qNeedsHelpMgr=TRUE");
  2087.         this->CatenateToSourceOptionStrings(" -d qNeedsProcessMgr=TRUE");
  2088.         this->CatenateToSourceOptionStrings(" -d qNeedsAliasMgr=TRUE");
  2089.         this->CatenateToSourceOptionStrings(" -d qNeedsFolderMgr=TRUE");
  2090.         this->CatenateToSourceOptionStrings(" -d qNeedsSystem7=TRUE");
  2091.         this->CatenateToSourceOptionStrings(" -d SystemSevenOrLater=TRUE");
  2092.         fOptionFlags->Catenate("Cq");
  2093.         this->CatenateToSourceOptionStrings(" -d qNeedsColorQD=TRUE");
  2094.         this->CatenateToSourceOptionStrings(" -d qNeedsFPU=FALSE");
  2095.     }
  2096.     else
  2097.     {
  2098.         // PreSystem 7.5 support
  2099.         if (fNeedsSystem7_5)
  2100.         {
  2101.             fOptionFlags->Catenate("75");
  2102.             this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=TRUE -d SystemSevenFiveOrLater=TRUE");
  2103.         }
  2104.         else
  2105.             this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=FALSE -d SystemSevenFiveOrLater=FALSE");
  2106.     
  2107.         // PreSystem 7.0 support
  2108.         if (fNeedsSystem7 || fNeedsSystem7_5)
  2109.         {
  2110.             if (!fNeedsSystem7_5)
  2111.                 fOptionFlags->Catenate("S7");
  2112.             this->CatenateToSourceOptionStrings(" -d qNeedsAppleEventMgr=TRUE -d qNeedsEditionMgr=TRUE -d qNeedsHelpMgr=TRUE -d qNeedsProcessMgr=TRUE -d qNeedsAliasMgr=TRUE -d qNeedsFolderMgr=TRUE -d qNeedsSystem7=TRUE -d SystemSevenOrLater=TRUE");
  2113.         }
  2114.         else
  2115.         {
  2116.             this->CatenateToSourceOptionStrings(" -d qNeedsAppleEventMgr=FALSE -d qNeedsEditionMgr=FALSE -d qNeedsHelpMgr=FALSE -d qNeedsProcessMgr=FALSE -d qNeedsAliasMgr=FALSE -d qNeedsFolderMgr=FALSE -d qNeedsSystem7=FALSE -d SystemSevenOrLater=FALSE");
  2117.             
  2118.             // Require System 6!
  2119.             this->CatenateToSourceOptionStrings(" -d SystemSixOrLater=FALSE");
  2120.         }
  2121.     
  2122.         // ColorQD support
  2123.         if (fNeedsColorQD)
  2124.         {
  2125.             fOptionFlags->Catenate("Cq");
  2126.             this->CatenateToSourceOptionStrings(" -d qNeedsColorQD=TRUE");
  2127.         }
  2128.         else
  2129.             this->CatenateToSourceOptionStrings(" -d qNeedsColorQD=FALSE");
  2130.     
  2131.         // 020 support
  2132.         if (fNeedsMC68020)
  2133.         {
  2134.             fOptionFlags->Catenate("20");
  2135.             this->CatenateToSourceOptionStrings(" -d qNeedsMC68020=TRUE");
  2136.             fCPlusCPUOptions->Catenate(" -mc68020");
  2137.         }
  2138.         else
  2139.             this->CatenateToSourceOptionStrings(" -d qNeedsMC68020=FALSE");
  2140.     
  2141.         // 030 support
  2142.         if (fNeedsMC68030)
  2143.         {
  2144.             fOptionFlags->Catenate("30");
  2145.             this->CatenateToSourceOptionStrings(" -d qNeedsMC68030=TRUE");
  2146.             fCPlusCPUOptions->Catenate(" -mc68020");
  2147.         }
  2148.         else
  2149.             this->CatenateToSourceOptionStrings(" -d qNeedsMC68030=FALSE");
  2150.     
  2151.         // 040 support
  2152.         if (fNeedsMC68040)
  2153.         {
  2154.             fOptionFlags->Catenate("40");
  2155.             this->CatenateToSourceOptionStrings(" -d qNeedsMC68040=TRUE");
  2156.             fCPlusCPUOptions->Catenate(" -mc68020");
  2157.         }
  2158.         else
  2159.             this->CatenateToSourceOptionStrings(" -d qNeedsMC68040=FALSE");
  2160.     
  2161.         // FPU support
  2162.         if (fNeedsFPU)
  2163.         {
  2164.             fOptionFlags->Catenate("Fp");
  2165.             this->CatenateToSourceOptionStrings(" -d qNeedsFPU=TRUE");
  2166.             if (fCompiler == kwMWC68K)
  2167.                 fCPlusCPUOptions->Catenate(" -mc68881");
  2168.             else
  2169.                 fCPlusCPUOptions->Catenate(" -mc68881 -elems881");
  2170.         }
  2171.         else
  2172.             this->CatenateToSourceOptionStrings(" -d qNeedsFPU=FALSE");
  2173.     
  2174.     } // fPowerPC
  2175.  
  2176.     // Virtual User support
  2177.     if (fNeedsVU)
  2178.     {
  2179.         fOptionFlags->Catenate("Vu");
  2180.  
  2181.         this->CatenateToSourceOptionStrings(" -d qNeedsVU=TRUE");
  2182.     }
  2183.     else
  2184.         this->CatenateToSourceOptionStrings(" -d qNeedsVU=FALSE");
  2185.  
  2186.     // The Debugger support
  2187.     if (fTheDebugger)
  2188.     {
  2189.         fOptionFlags->Catenate("J");
  2190.  
  2191.         this->CatenateToSourceOptionStrings(" -d qTheDebugger=TRUE");
  2192.     }
  2193.     else
  2194.         this->CatenateToSourceOptionStrings(" -d qTheDebugger=FALSE");
  2195.  
  2196.     // Embedded debugger names
  2197.     if (fNames)
  2198.     {
  2199.         fOptionFlags->Catenate("Nm");
  2200.         fMWC68KOptions->Catenate(" -mbg full");
  2201.  
  2202.         this->CatenateToSourceOptionStrings(" -d qNames=TRUE");
  2203.     }
  2204.     else
  2205.     {
  2206.         this->CatenateToSourceOptionStrings(" -d qNames=FALSE");
  2207.         if (!fPowerPC)
  2208.         {
  2209.             fCOptions->Catenate(" -mbg off");
  2210.             fMWC68KOptions->Catenate(" -mbg off");
  2211.             fCPlusOptions->Catenate(" -mbg off");
  2212.             fSCOptions->Catenate(" -mbg off");
  2213.         }
  2214.     }
  2215.  
  2216.     // Debugging support
  2217.     if (fDebug)
  2218.     {
  2219.         fOptionFlags->Catenate("Db");
  2220.         this->CatenateToSourceOptionStrings(" -d qDebug=TRUE");
  2221.     }
  2222.     else
  2223.         this->CatenateToSourceOptionStrings(" -d qDebug=FALSE");
  2224.  
  2225.     // Inspector support
  2226.     if (fInspector)
  2227.     {
  2228.         fOptionFlags->Catenate("In");
  2229.         this->CatenateToSourceOptionStrings(" -d qInspector=TRUE");
  2230.     }
  2231.     else
  2232.         this->CatenateToSourceOptionStrings(" -d qInspector=FALSE");
  2233.  
  2234.     // Debug messages support
  2235.     if (fDebugMsg)
  2236.     {
  2237.         fOptionFlags->Catenate("Dm");
  2238.         this->CatenateToSourceOptionStrings(" -d qDebugMsg=TRUE");
  2239.     }
  2240.     else
  2241.         this->CatenateToSourceOptionStrings(" -d qDebugMsg=FALSE");
  2242.  
  2243.     // Perform support
  2244.     if (fPerform)
  2245.     {
  2246.         fOptionFlags->Catenate("Pe");
  2247.         this->CatenateToSourceOptionStrings(" -d qPerform=TRUE");
  2248.     }
  2249.     else
  2250.         this->CatenateToSourceOptionStrings(" -d qPerform=FALSE");
  2251.  
  2252.     // RangeCheck support
  2253.     if (fRangeCheck)
  2254.     {
  2255.         fOptionFlags->Catenate("Ra");
  2256.         this->CatenateToSourceOptionStrings(" -d qRangeCheck=TRUE");
  2257.     }
  2258.     else
  2259.         this->CatenateToSourceOptionStrings(" -d qRangeCheck=FALSE");
  2260.  
  2261.     // Attachability support
  2262.     if (fAttachable)
  2263.     {
  2264.         fOptionFlags->Catenate("At");
  2265.         this->CatenateToSourceOptionStrings(" -d qAttachable=TRUE");
  2266.     }
  2267.     else
  2268.         this->CatenateToSourceOptionStrings(" -d qAttachable=FALSE");
  2269.  
  2270.     // Drag & Drop support
  2271.     if (fDrag)
  2272.     {
  2273.         fOptionFlags->Catenate("Dr");
  2274.         this->CatenateToSourceOptionStrings(" -d qDrag=TRUE");
  2275.     }
  2276.     else
  2277.         this->CatenateToSourceOptionStrings(" -d qDrag=FALSE");
  2278.  
  2279.     // GX Printing support
  2280.     if (fGXPrinting)
  2281.     {
  2282.         if (!fNeedsGX)
  2283.             fOptionFlags->Catenate("Gp");
  2284.         this->CatenateToSourceOptionStrings(" -d qGXPrinting=TRUE");
  2285.     }
  2286.     else
  2287.         this->CatenateToSourceOptionStrings(" -d qGXPrinting=FALSE");
  2288.  
  2289.     // GX Views support
  2290.     if (fGXViews)
  2291.     {
  2292.         if (!fNeedsGX)
  2293.             fOptionFlags->Catenate("Gv");
  2294.         this->CatenateToSourceOptionStrings(" -d qGXViews=TRUE");
  2295.     }
  2296.     else
  2297.         this->CatenateToSourceOptionStrings(" -d qGXViews=FALSE");
  2298.  
  2299.     // NeedsGX support
  2300.     if (fNeedsGX)
  2301.     {
  2302.         fOptionFlags->Catenate("GX");
  2303.         this->CatenateToSourceOptionStrings(" -d qNeedsGX=TRUE");
  2304.     }
  2305.     else
  2306.         this->CatenateToSourceOptionStrings(" -d qNeedsGX=FALSE");
  2307.  
  2308.     // PowerTalk support
  2309.     if (fPowerTalk)
  2310.     {
  2311.         fOptionFlags->Catenate("Pt");
  2312.         this->CatenateToSourceOptionStrings(" -d qPowerTalk=TRUE");
  2313.     }
  2314.     else
  2315.         this->CatenateToSourceOptionStrings(" -d qPowerTalk=FALSE");
  2316.  
  2317.     // OpenDoc support
  2318.     if (fContainer /* || fPart */)
  2319.     {
  2320.         fOptionFlags->Catenate("OD");
  2321.         this->CatenateToSourceOptionStrings(" -d qOpenDoc=TRUE");
  2322.     }
  2323.     else
  2324.         this->CatenateToSourceOptionStrings(" -d qOpenDoc=FALSE");
  2325.  
  2326.     // Container application support
  2327.     if (fContainer)
  2328.     {
  2329.         fOptionFlags->Catenate("Ca");
  2330.         this->CatenateToSourceOptionStrings(" -d qContainer=TRUE");
  2331.     }
  2332.     else
  2333.         this->CatenateToSourceOptionStrings(" -d qContainer=FALSE");
  2334.  
  2335.     // template views support
  2336.     if (fTemplateViews)
  2337.     {
  2338.         fOptionFlags->Catenate("Te");
  2339.         this->CatenateToSourceOptionStrings(" -d qTemplateViews=TRUE");
  2340.     }
  2341.     else
  2342.         this->CatenateToSourceOptionStrings(" -d qTemplateViews=FALSE");
  2343.  
  2344.     // writing template views support
  2345.     if (fWriteTemplateViews)
  2346.     {
  2347.         fOptionFlags->Catenate("Wr");
  2348.         this->CatenateToSourceOptionStrings(" -d qWriteTemplateViews=TRUE");
  2349.     }
  2350.     else
  2351.         this->CatenateToSourceOptionStrings(" -d qWriteTemplateViews=FALSE");
  2352.  
  2353.     // symbolic debugging support
  2354.     if (fSym)
  2355.     {
  2356.         fOptionFlags->Catenate("Sm");
  2357.         this->CatenateToSourceOptionStrings(" -d qSym=TRUE");
  2358.         
  2359. //CW added symOn and fullPath
  2360.         const CStr255 symOn = " -sym on";
  2361.         const CStr255 fullpath = "  -sym full";
  2362.         if (!fPowerPC)
  2363.         {
  2364.             CStr255 aString;
  2365.  
  2366.             if (fSmallSym)
  2367.                 aString = " -sym on,notypes,novars";
  2368.             else
  2369.                 aString = symOn; 
  2370.  
  2371.             fAsmOptions->Catenate(aString);
  2372.             fCOptions->Catenate(aString);
  2373.  
  2374.             if (fTheDebugger)
  2375.                 fMWLink68KOptions->Catenate(" -sym tdb");
  2376.             fMWC68KOptions->Catenate(fullpath);
  2377.             fMWC68KOptions->Catenate(" -a6");
  2378.             fMWLink68KOptions->Catenate(fullpath);
  2379.  
  2380.             fCPlusOptions->Catenate(aString);
  2381.             fSCOptions->Catenate(aString);
  2382.             fLinkOptions->Catenate(aString);
  2383.         }
  2384.         else
  2385.         {
  2386.             fAsmOptions->Catenate(symOn);
  2387.             fPPCCOptions->Catenate(symOn);
  2388.             fMrCOptions->Catenate(symOn);
  2389.         
  2390.             // big sym support
  2391.             if (fCompiler == kwMWCPPC)
  2392.             {
  2393.                 fMWCPPCOptions->Catenate(fullpath);
  2394.                 fMWLinkPPCOptions->Catenate(fullpath);
  2395.             }
  2396.             else if (fSmallSym)
  2397.             {
  2398.                 fPPCLibOptions->Catenate(symOn);
  2399.                 fPPCLinkOptions->Catenate(symOn);
  2400.             }
  2401.             else
  2402.             {
  2403.                 fPPCLibOptions->Catenate(" -sym big");
  2404.                 fPPCLinkOptions->Catenate(" -sym big");
  2405.                 fMakeSymOptions->Catenate(" -sym big");
  2406.             }
  2407.         }
  2408.     }
  2409.     else
  2410.         this->CatenateToSourceOptionStrings(" -d qSym=FALSE");
  2411.  
  2412. }
  2413.  
  2414. //----------------------------------------------------------------------------------------
  2415. // TMABuildTool::DoOptionFlags_Part2: 
  2416. //----------------------------------------------------------------------------------------
  2417. #pragma segment ANonRes
  2418.  
  2419. void TMABuildTool::DoOptionFlags_Part2(void)
  2420. {
  2421.     // Model far support
  2422.     if (fCompiler == kwMWC68K)
  2423.     {
  2424.         if ((fModelFarCode && fModelFarData) || fModelFar)
  2425.         {
  2426.             fOptionFlags->Catenate("fCfD");
  2427.             fMWC68KOptions->Catenate(" -model far");
  2428.             fMWLink68KOptions->Catenate(" -model far");
  2429.                 
  2430.             this->CatenateToSourceOptionStrings(" -d qModelFarData=TRUE");
  2431.             this->CatenateToSourceOptionStrings(" -d qModelFarCode=TRUE");
  2432.         }
  2433.         else if (fModelFarCode)
  2434.         {
  2435.             fOptionFlags->Catenate("fC");
  2436.             
  2437.             fMWC68KOptions->Catenate(" -model farCode");
  2438.             fMWLink68KOptions->Catenate(" -model far");
  2439.             this->CatenateToSourceOptionStrings(" -d qModelFarData=FALSE");
  2440.             this->CatenateToSourceOptionStrings(" -d qModelFarCode=TRUE");
  2441.         }
  2442.         else if (fModelFarData)
  2443.         {
  2444.             fOptionFlags->Catenate("fD");
  2445.             
  2446.             fMWC68KOptions->Catenate(" -model farData");
  2447.             fMWC68KOptions->Catenate(" -model farstrings");
  2448.             fMWC68KOptions->Catenate(" -model farvtables");
  2449.                 
  2450.             this->CatenateToSourceOptionStrings(" -d qModelFarData=TRUE");
  2451.             this->CatenateToSourceOptionStrings(" -d qModelFarCode=FALSE");
  2452.         }
  2453.         else
  2454.         {
  2455.             this->CatenateToSourceOptionStrings(" -d qModelFarData=FALSE");
  2456.             this->CatenateToSourceOptionStrings(" -d qModelFarCode=FALSE");
  2457.         }
  2458.     }
  2459.     else
  2460.     {
  2461.         if (fModelFarCode || fModelFarData || fModelFar)
  2462.         {
  2463.             fModelFar = TRUE;
  2464.             fOptionFlags->Catenate("fCfD");
  2465.             fCOptions->Catenate(" -model farCode -model farData");
  2466.             fRunTimeModel->Catenate(" -model far");
  2467.                 
  2468.             this->CatenateToSourceOptionStrings(" -d qModelFarData=TRUE");
  2469.             this->CatenateToSourceOptionStrings(" -d qModelFarCode=TRUE");
  2470.         }
  2471.         else
  2472.         {
  2473.             this->CatenateToSourceOptionStrings(" -d qModelFarData=FALSE");
  2474.             this->CatenateToSourceOptionStrings(" -d qModelFarCode=FALSE");
  2475.             if (!fModelCFM)
  2476.                 fLinkOptions->Catenate(" -wrap");
  2477.         }
  2478.     }
  2479.  
  2480.     // Model CFM-68K support
  2481.     if (fModelCFM)
  2482.     {
  2483.         fOptionFlags->Catenate("CF");
  2484.         fRunTimeModel->Catenate(" -model cfmseg");
  2485.         this->CatenateToSourceOptionStrings(" -d qModelCFM=TRUE");
  2486.     }
  2487.     else
  2488.     {
  2489.         this->CatenateToSourceOptionStrings(" -d qModelCFM=FALSE");
  2490.     }
  2491.     
  2492.     // Classic 68K runtime support
  2493.     if (fClassic)
  2494.     {
  2495.         fOptionFlags->Catenate("Cl");
  2496.         this->CatenateToSourceOptionStrings(" -d qClassic=TRUE");
  2497.     }
  2498.     else
  2499.     {
  2500.         this->CatenateToSourceOptionStrings(" -d qClassic=FALSE");
  2501.     }
  2502.     
  2503.     // PowerPC support
  2504.     if (fPowerPC)
  2505.     {
  2506.         this->CatenateToSourceOptionStrings(" -d qPowerPC=TRUE");
  2507.     }
  2508.     else
  2509.     {
  2510.         // We're not building a native app
  2511.         this->CatenateToSourceOptionStrings(" -d qPowerPC=FALSE");
  2512.     }
  2513.  
  2514.     // Add the compiler
  2515.     switch (fCompiler)
  2516.     {
  2517.         case kwSCpp:
  2518.             fOptionFlags->Catenate("SC");
  2519.             break;
  2520.         
  2521.         case kwMrC:
  2522.             fOptionFlags->Catenate("Mr");
  2523.             break;
  2524.         
  2525.         case kwMWCPPC:
  2526.             fOptionFlags->Catenate("MW");
  2527.             break;
  2528.         
  2529.         case kwMWC68K:
  2530.             fOptionFlags->Catenate("M8");
  2531.             break;
  2532.         
  2533.         default:
  2534.             break;
  2535.     }
  2536.  
  2537.     // Process separate objects
  2538.     // Get basic name
  2539.     if (fSeparateObjects)
  2540.     {
  2541.         CStr255 tempString(fOptionFlags->AsStr255());
  2542.         if (!fRenameFlagsPairs->ValueAt(tempString, fSeparateObjectsFolder))
  2543.             fSeparateObjectsFolder = tempString;
  2544.     }
  2545.     else
  2546.     {
  2547.         if (!IEgetenv("MANoSeparateObjectsFolder", fSeparateObjectsFolder))
  2548.             fSeparateObjectsFolder.Empty();
  2549.     }
  2550.  
  2551.     // Add the prefix
  2552.     CStr255 MASeparateObjectsPrefix;
  2553.     if (IEgetenv("MASeparateObjectsPrefix", MASeparateObjectsPrefix))
  2554.         fSeparateObjectsFolder = MASeparateObjectsPrefix + fSeparateObjectsFolder;
  2555.  
  2556.     if (fSeparateObjectsFolder.Length() > 31)
  2557.     {
  2558.         fprintf(stderr, "\nMABuild: Warning: SeparateObjectsFolder '%s'; truncated to 31 characters\n",
  2559.                 (const char *) fSeparateObjectsFolder);
  2560.         fSeparateObjectsFolder.Length() = 31;
  2561.     }
  2562.     
  2563.     fSeparateObjectsFolder += gDirectorySeparator;
  2564.  
  2565.     this->SetIE("SeparateObjectsFolder", fSeparateObjectsFolder);
  2566.  
  2567.     if (fRAMDisk)
  2568.     {
  2569.         fPPCCOptions->Catenate(" -y '");
  2570.         fPPCCOptions->Catenate(fRAMDiskName);
  2571.         fPPCCOptions->Catenate("'");
  2572.  
  2573.         fMrCOptions->Catenate(" -y '");
  2574.         fMrCOptions->Catenate(fRAMDiskName);
  2575.         fMrCOptions->Catenate("'");
  2576.     }
  2577.     
  2578.     // Include any unconditional options that we might want to force on unsuspecting
  2579.     // tools but haven't the gall to include in the startup file.
  2580. }
  2581.  
  2582. //----------------------------------------------------------------------------------------
  2583. // TMABuildTool::OutputOptionFlags: 
  2584. //----------------------------------------------------------------------------------------
  2585. #pragma segment ANonRes
  2586.  
  2587. void TMABuildTool::OutputOptionFlags()
  2588. {
  2589.     // output the results.
  2590.     if (fTimes)
  2591.         fprintf(fOutputFile,"SET XStartTime %li\n",fStartDateTime);
  2592.     
  2593.     if (fRAMDisk && fCPlusLoad)
  2594.         this->SetIE("XRAMDiskLoad", "0");
  2595.     
  2596.     if (fFast)
  2597.     {
  2598.         fprintf(fOutputFile, "SET All_Cpp_Files \"\"\n");
  2599.         fprintf(fOutputFile, "SET All_Cpp_Names \"\"\n");
  2600.         fprintf(fOutputFile, "SET All_C_Files \"\"\n");
  2601.         fprintf(fOutputFile, "SET All_C_Names \"\"\n");
  2602.     }
  2603.  
  2604.     this->SetIE("MakeOptions", fMakeOptions);
  2605.     this->SetIE("XOptionFlags", fOptionFlags);
  2606. }
  2607.  
  2608. //----------------------------------------------------------------------------------------
  2609. // TMABuildTool::ParseTargetName: 
  2610. //----------------------------------------------------------------------------------------
  2611. #pragma segment ANonRes
  2612.  
  2613. void TMABuildTool::ParseTargetName(CStr255& targetName)
  2614. {
  2615.     // find the pathname and filename
  2616.  
  2617.     SubstituteInString(targetName);
  2618.     
  2619.     fAppName = targetName;
  2620.     fAppPath.Empty();
  2621.     
  2622.     for (short i = targetName.Length(); i >= 1; i--)
  2623.     {
  2624.         if (targetName.Copy(i, gDirectorySeparator.Length()) == gDirectorySeparator)
  2625.         {
  2626.             fAppPath = targetName.Copy(1, i);
  2627.             fAppName = targetName.Copy(i + 1, targetName.Length() - i);
  2628.             break;
  2629.         }
  2630.     }
  2631.     
  2632.     // Automatically trim .MAMake off the target name if it was specified
  2633.     if (IEgetenv("MAMakeFileExtension", fMAMakeFileExtension) && !fMAMakeFileExtension.IsEmpty())
  2634.     {
  2635.         CStr255 aString(fMAMakeFileExtension);
  2636.         CStr255 bString(fAppName);
  2637.         UprStr255(aString);
  2638.         UprStr255(bString);
  2639.         short j = aString.Pos(bString);
  2640.         if ((j != 0) && (j + aString.Length() - 1 == fAppName.Length()))
  2641.             fAppName.Delete(j, aString.Length());
  2642.     }
  2643.  
  2644.     // Blank path is current path
  2645.     if (fAppPath.IsEmpty())
  2646.         fAppPath = fStartPath;
  2647. }
  2648.  
  2649. //----------------------------------------------------------------------------------------
  2650. // TMABuildTool::CheckSources: 
  2651. //----------------------------------------------------------------------------------------
  2652. #pragma segment ANonRes
  2653.  
  2654. //    Boolean TMABuildTool::CheckSources(const CStr255& srcVar, const CStr255& srcFile,
  2655. //                                       const CStr255& objVar, const CStr255& objFile)
  2656. //    {
  2657. //        Boolean exists = this->Exists(srcFile);
  2658. //        if (exists)
  2659. //        {
  2660. //            this->SetIE(srcVar, srcFile);
  2661. //            if (objVar.Length() > 0)
  2662. //                this->SetIE(objVar, objFile);
  2663. //        }
  2664. //        else
  2665. //        {
  2666. //            this->SetIE(srcVar, "");
  2667. //            if (objVar.Length() > 0)
  2668. //                this->SetIE(objVar, "");
  2669. //        }
  2670. //        return exists;
  2671. //    }
  2672.  
  2673. //----------------------------------------------------------------------------------------
  2674. // TMABuildTool::CreateBuildFolder: 
  2675. //----------------------------------------------------------------------------------------
  2676. #pragma segment ANonRes
  2677.  
  2678. void TMABuildTool::CreateBuildFolder()
  2679. {
  2680.     // Define the MAObj folder. We do this here because its used in building
  2681.     // each target. see 'Basic Definitions'/'Basic DefinitionsFT'
  2682.         
  2683.     this->SetIE("BuildFolder", fBuildFolder);
  2684.     
  2685.     if (fBuildFolder.Length() > 0)
  2686.     {
  2687.         fMAObj = fBuildFolder;
  2688.         CreateFolder(fMAObj);
  2689.         
  2690.         fMAObj += "MacApp.Lib";
  2691.         CreateFolder(fMAObj);
  2692.             
  2693.         fMAObj += gDirectorySeparator + fSeparateObjectsFolder;
  2694.         this->SetIE("MAObj", fMAObj);
  2695.         CreateFolder(fMAObj);
  2696.     }
  2697.     else
  2698.     {
  2699.         IEgetenv("MALibraries", fMAObj);
  2700.         fMAObj += fSeparateObjectsFolder;
  2701.         this->SetIE("MAObj", fMAObj);
  2702.     }
  2703. }
  2704.  
  2705. //----------------------------------------------------------------------------------------
  2706. // TMABuildTool::CreateObjectsFolder: 
  2707. //----------------------------------------------------------------------------------------
  2708. #pragma segment ANonRes
  2709.  
  2710. void TMABuildTool::CreateObjectsFolder()
  2711. {
  2712.     // Make sure alternate build folder exists and AppName folder in build folder.
  2713.     if (fBuildFolder.Length() > 0)
  2714.         CreateFolder(fBuildFolderAppName);
  2715.  
  2716.     // Make sure separate objects folder exists
  2717.     CreateFolder(fObjApp);
  2718. }
  2719.  
  2720. //----------------------------------------------------------------------------------------
  2721. // TMABuildTool::DoAllTargets: 
  2722. //----------------------------------------------------------------------------------------
  2723. #pragma segment ANonRes
  2724.  
  2725. void TMABuildTool::DoAllTargets()
  2726. {
  2727.     // Now process every target in fTargStringList
  2728.     
  2729.     TStringHandle* stringHandle = (TStringHandle*)(fTargStringList->First());
  2730.     while (stringHandle != NULL)
  2731.     {
  2732.         fTargStringList->Delete(stringHandle);
  2733.  
  2734.         this->ParseTargetName(stringHandle->AsStr255());// Paths can't currently be longer than this anyways! (MPW 3.1)
  2735.         stringHandle->Free();
  2736.  
  2737.         //CW had to split these up because of 32K local data limitation
  2738.         this->DoATarget_Part1();
  2739.         this->DoATarget_Part2();
  2740.         
  2741.         stringHandle = (TStringHandle*)(fTargStringList->First());
  2742.     }
  2743. }
  2744.  
  2745. //----------------------------------------------------------------------------------------
  2746. // TMABuildTool::DoATarget_Part1: 
  2747. //----------------------------------------------------------------------------------------
  2748. #pragma segment ANonRes
  2749.  
  2750. void TMABuildTool::DoATarget_Part1()
  2751. {
  2752.     this->SetIE("XAppPath", fAppPath);
  2753.     this->SetIE("XAppName", fAppName);
  2754.  
  2755.     // Check for the  MASetupExtension file
  2756.     {
  2757.         CStr255 MASetupExtension;
  2758.         if (IEgetenv("MASetupExtension", MASetupExtension))
  2759.         {
  2760.             CStr255 aString = fAppPath + fAppName + MASetupExtension;
  2761.             if (Exists(aString))
  2762.                 fprintf(fOutputFile,"EXECUTE \"%s\"\n",(const char *)aString);
  2763.         }
  2764.     }
  2765.  
  2766.     // Process separate objects into the source and object pathnames…
  2767.     if (fBuildFolder.Length() > 0)
  2768.     {
  2769.         fBuildFolderAppName = fBuildFolder;
  2770.         if (fAppName == "MacApp.lib.xcoff")
  2771.             fBuildFolderAppName += "MacApp.Lib";
  2772.         else
  2773.             fBuildFolderAppName += fAppName;
  2774.         fObjApp = fBuildFolderAppName + gDirectorySeparator + fSeparateObjectsFolder;
  2775.     }
  2776.     else
  2777.     {
  2778.         fBuildFolderAppName.Empty();
  2779.         fObjApp = fAppPath + fSeparateObjectsFolder;
  2780.     }
  2781.  
  2782.     fSrcApp = fAppPath;
  2783.     
  2784.     {
  2785.         CStr255 MASourcesFolder;
  2786.         if (IEgetenv("MASourcesFolder", MASourcesFolder))
  2787.         {
  2788.             CStr255 srcAppSrc = fSrcApp + MASourcesFolder;
  2789.             if (Exists(srcAppSrc))
  2790.                 fSrcApp = srcAppSrc;
  2791.         }
  2792.     }
  2793.     
  2794.     this->SetIE("ObjApp", fObjApp);
  2795.     //this->SetIE("LoadFileDir", fObjApp);
  2796.     this->SetIE("SrcApp", fSrcApp);
  2797.     
  2798.     {
  2799.         fIncApp = fAppPath;
  2800.         CStr255 MAIncludesFolder;
  2801.         if (IEgetenv("MAIncludesFolder", MAIncludesFolder))
  2802.         {
  2803.             short saveLen = fIncApp.Length();
  2804.             fIncApp += MAIncludesFolder;
  2805.             if (!Exists(fIncApp))
  2806.                 fIncApp.Length() = saveLen;
  2807.         }
  2808.         this->SetIE("IncApp", fIncApp);
  2809.     }
  2810.     
  2811.     if (fProgress)
  2812.         this->Echo("\"Target Folder: ∂\"{ObjApp}∂\"\"");
  2813.      
  2814.     // Linkmap and LinkXref
  2815.     if (fLinkMap)
  2816.     {
  2817.         if (fCompiler == kwMWC68K || fCompiler == kwMWCPPC)
  2818.             fXLinkMap = "-map > \"{ObjApp}{XAppName}.map\" ";
  2819.         else if (!fPowerPC && fPerform)
  2820.             fXLinkMap = "-la -lf -l > \"{ObjApp}{XAppName}.map\" ";
  2821.         else
  2822.             fXLinkMap = "-map  \"{ObjApp}{XAppName}.map\" ";
  2823.     }
  2824.     else
  2825.         fXLinkMap.Empty();
  2826.     
  2827. //SRF    this->SetIE("XLinkMap", fXLinkMap);
  2828.     this->SetMakeVariable("XLinkMap", fXLinkMap);
  2829.     
  2830.     if (fLinkXRef && (fCompiler != kwMWC68K && fCompiler != kwMWCPPC))
  2831.         fXLinkXRef = "-x \"{ObjApp}{XAppName}.xref\" ";
  2832.     else
  2833.         fXLinkXRef.Empty();
  2834.     
  2835. //SRF    this->SetIE("XLinkXRef", fXLinkXRef);
  2836.     this->SetMakeVariable("XLinkXRef", fXLinkXRef);
  2837.     
  2838.     // in C++
  2839.     fAnyCPlus = FALSE;
  2840.  
  2841.     fXUAppName_h.Empty();
  2842.     fXUAppName_cp.Empty();
  2843.     fXUAppName_cp_o.Empty();
  2844.     fXMAppName_cp.Empty();
  2845.     fXMAppName_cp_o.Empty();
  2846.     fXAppName_cp.Empty();
  2847.     fXAppName_cp_o.Empty();
  2848.     
  2849.     if (!fRSRC)
  2850.     {
  2851.         CStr255 fileName;
  2852.         
  2853.         fileName = fSrcApp + "U" + fAppName + ".h";
  2854.         if (this->Exists(fileName))
  2855.         {
  2856.             fAnyCPlus = TRUE;
  2857.             fXUAppName_h = fileName;
  2858.         }
  2859.     
  2860.         fileName = "U" + fAppName + ".cp";
  2861.         if (this->Exists(fSrcApp + fileName))
  2862.         {
  2863.             fAnyCPlus = TRUE;
  2864.             fXUAppName_cp = fSrcApp + fileName;
  2865.             fXUAppName_cp_o = fObjApp + fileName + ".o";
  2866.         }
  2867.     
  2868.         fileName = "M" + fAppName + ".cp";
  2869.         if (this->Exists(fSrcApp + fileName))
  2870.         {
  2871.             fAnyCPlus = TRUE;
  2872.             fXMAppName_cp = fSrcApp + fileName;
  2873.             fXMAppName_cp_o = fObjApp + fileName + ".o";
  2874.         }
  2875.     
  2876.         fileName = fAppName + ".cp";
  2877.         if (this->Exists(fSrcApp + fileName))
  2878.         {
  2879.             fAnyCPlus = TRUE;
  2880.             fXAppName_cp = fSrcApp + fileName;
  2881.             fXAppName_cp_o = fObjApp + fileName + ".o";
  2882.         }
  2883.     }
  2884.     
  2885.     this->SetIE("XUAppName.h", fXUAppName_h);
  2886.     this->SetIE("XUAppName.cp", fXUAppName_cp);
  2887.     this->SetIE("XUAppName.cp.o", fXUAppName_cp_o);
  2888.     this->SetIE("XMAppName.cp", fXMAppName_cp);
  2889.     this->SetIE("XMAppName.cp.o", fXMAppName_cp_o);
  2890.     this->SetIE("XAppName.cp", fXAppName_cp);
  2891.     this->SetIE("XAppName.cp.o", fXAppName_cp_o);
  2892.  
  2893.     // See if we can automake it
  2894.     if (!Exists(fAppPath + fAppName + fMAMakeFileExtension))
  2895.     {
  2896.         fAutomake = TRUE;
  2897.         if (!fAnyCPlus && !fRSRC)
  2898.         {
  2899.             this->Failed("Bad parameter: Unable to access file: \"{XAppPath}{XAppName}{MAMakeFileExtension}\"");
  2900.         }
  2901.     }
  2902.     else
  2903.         fAutomake = FALSE;
  2904.  
  2905.     // See if we can autorez it
  2906.     if (!Exists(fAppPath + fAppName + ".r"))
  2907.     {
  2908.         fAutorez = TRUE;
  2909.         this->SetIE("XAutoRez", "1");
  2910.         this->SetIE("XAppRezSrc", "{MAFramework}Includes:Default.r");
  2911.     }
  2912.     else
  2913.     {
  2914.         fAutorez = FALSE;
  2915.         this->SetIE("XAutoRez", "0");
  2916.         this->SetIE("XAppRezSrc", "{XAppPath}{XAppName}.r");
  2917.     }
  2918. }
  2919.  
  2920. //----------------------------------------------------------------------------------------
  2921. // TMABuildTool::DoATarget_Part2: 
  2922. //----------------------------------------------------------------------------------------
  2923. #pragma segment ANonRes
  2924.  
  2925. void TMABuildTool::DoATarget_Part2()
  2926. {
  2927.     // Make sure alternate build folder exists and AppName folder in build folder.
  2928.     this->CreateObjectsFolder();
  2929.  
  2930.     // SET the BuildFlags
  2931.     {
  2932.         CStr255 MABuildFlagsExtension;
  2933.         IEgetenv("MABuildFlagsExtension", MABuildFlagsExtension);
  2934.         fBuildFlags = fObjApp + fAppName + MABuildFlagsExtension;
  2935.     }
  2936.     this->SetIE("BuildFlags", fBuildFlags);
  2937.  
  2938.     // Find out what the last option flags were
  2939.     Boolean existsBuildFlags = Exists(fBuildFlags);
  2940.     if (existsBuildFlags)
  2941.         this->Execute("EXECUTE \"{BuildFlags}\" ∑ Dev:NULL || SET Status 0");
  2942.     else
  2943.         this->SetIE("XLastOptionFlags", "InvalidString");
  2944.     
  2945.     if (fExecute)
  2946.     {
  2947.         this->Execute("IF {XLastOptionFlags} != {XOptionFlags}");
  2948.         // the file BuildFlags will contain a SET command to set the value of XLastOptionFlags
  2949.         this->Execute("ECHO \"SET XLastOptionFlags {XOptionFlags}\"  >  \"{BuildFlags}\"");
  2950.         this->Execute("END");
  2951.     }
  2952.     else if (!existsBuildFlags)
  2953.     {
  2954.         // the file BuildFlags will contain a SET command to set the value of XLastOptionFlags
  2955.         this->Echo("\"SET XLastOptionFlags {XOptionFlags}\"  >  \"{BuildFlags}\"");
  2956.     }
  2957.  
  2958.     // Rebuild the application by creating the "MakeIt" file and then executing it
  2959.     this->SetIE("XMakeIt", "{ObjApp}{XAppName}{MAMakeOutfileExtension}");
  2960.  
  2961.     // SET the failure processing mode in the makeit files and (OPTIONALLY) the
  2962.     // active environment vars into the makefile
  2963.     if (fNoFail)
  2964.         this->Execute("ECHO \"SET EXIT 0\"  > \"{XMakeIt}\"");
  2965.     else
  2966.         this->Execute("ECHO \"SET EXIT 1\"  > \"{XMakeIt}\"");
  2967.     
  2968.     //    if (fExpandEnvironmentVars)
  2969.     //        this->ExpandEnvironmentVars();
  2970.  
  2971.     //    // Export the various and sundry environment variables
  2972.     //    if (!fEverExported)
  2973.     //    {
  2974.     //        fEverExported = TRUE;                    // only need to export once
  2975.     //        this->ExportEnvironmentVars();
  2976.     //    }
  2977.  
  2978.     //if (!fRSRC)
  2979.     //{
  2980.     // Give user makefile processing status message
  2981.     if (fProgress)
  2982.     {
  2983.         if (fAutomake)
  2984.             this->Echo("\"AutoMaking:    {XAppName}\"");
  2985.         else
  2986.             this->Echo("\"Making:        {XAppName}{MAMakeFileExtension}\"");
  2987.     }
  2988.     //}
  2989.  
  2990.     if (fTimes)
  2991.         this->SetIE("XMakeStartTime", "`DATE -n`");
  2992.     this->SetIE("EXIT", "0");
  2993.  
  2994.     // Create the make file
  2995.     this->CreateMakeFile();
  2996.  
  2997.     // run make
  2998.     this->MakeTarget();
  2999.  
  3000.     this->SetIE("XMakeStatus", "{Status}");
  3001.     this->SetIE("EXIT", "1");
  3002.     this->Execute("IF \"{XMakeStatus}\"");
  3003.     this->Echo("MAKE of {XAppName} failed: `DATE`");
  3004.     if (fTimes)
  3005.         this->Echo("Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds");
  3006.     this->Execute("{MAFailed}");
  3007.     if (fNoFail)
  3008.         this->SetIE("XExitStatus", "{XMakeStatus}");
  3009.     else
  3010.         this->Execute("EXIT \"{XMakeStatus}\"");
  3011.     
  3012.     if (fTimes)
  3013.     {
  3014.         this->Execute("ELSE");
  3015.         this->Echo("Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds");
  3016.     }
  3017.     this->Execute("END");
  3018.  
  3019.     // Attempt Execution and let the user know how it all came out
  3020.     if (fExecute)
  3021.     {
  3022.         this->SetIE("EXIT", "0");
  3023.         this->Execute("\"{XMakeIt}\"");
  3024.         this->SetIE("XRunStatus", "{Status}");
  3025.         this->SetIE("EXIT", "1");
  3026.         this->Execute("IF \"{XRunStatus}\"");
  3027.         this->Execute("{MAFailed}");
  3028.         if (fNoFail)
  3029.             this->SetIE("XExitStatus", "{XRunStatus}");
  3030.         else
  3031.             this->Execute("EXIT \"{XRunStatus}\"");
  3032.         this->Execute("END");
  3033.     }
  3034. }
  3035.  
  3036. //----------------------------------------------------------------------------------------
  3037. // TMABuildTool::ExpandEnvironmentVars: 
  3038. //----------------------------------------------------------------------------------------
  3039. #pragma segment ANonRes
  3040.  
  3041. void TMABuildTool::ExpandEnvironmentVars()
  3042. {
  3043. }
  3044.  
  3045. //----------------------------------------------------------------------------------------
  3046. // TMABuildTool::ExportEnvironmentVars: 
  3047. //----------------------------------------------------------------------------------------
  3048. #pragma segment ANonRes
  3049.  
  3050. void TMABuildTool::ExportEnvironmentVars()
  3051. {
  3052. }
  3053.  
  3054. //----------------------------------------------------------------------------------------
  3055. // TMABuildTool::CreateMakeFile: 
  3056. //----------------------------------------------------------------------------------------
  3057. #pragma segment ANonRes
  3058.  
  3059. void TMABuildTool::CreateMakeFile()
  3060. {
  3061.     CStr255 makeFileName = fObjApp + fAppName + ".make";
  3062.     fMakeFile = fopen(makeFileName, "w");
  3063.     
  3064.     fprintf(fMakeFile, "# %s\n", (const char *) makeFileName);
  3065.     {
  3066.         unsigned long theDateTime;
  3067.         CStr255 theDateTimeString;
  3068.         
  3069.         GetDateTime(&theDateTime);
  3070.     
  3071.         IUTimeString(theDateTime, TRUE, theDateTimeString);
  3072.         fprintf(fMakeFile, "# Created by MABuild: %s", (const char *)theDateTimeString);
  3073.     
  3074.         IUDateString(theDateTime, shortDate, theDateTimeString);
  3075.         fprintf(fMakeFile, " %s\n\n", (const char *)theDateTimeString);
  3076.     }
  3077.  
  3078.     this->OutputMakeVariables();
  3079.  
  3080.     this->DoDefinitions();
  3081.     
  3082.     if (fAutomake)
  3083.         this->SetMakeVariable("AppName", fAppName);     // the default rules supply the rest
  3084.     
  3085.     if (fFat)
  3086.         this->SetMakeVariable("Merge68K", fAppName68K);
  3087.     
  3088.     this->DoOverrides();
  3089.     
  3090.     if (!fAutomake)
  3091.         this->CatenateMake(fAppPath + fAppName + fMAMakeFileExtension); // a makefile was supplied
  3092.     
  3093.     this->DoDependencies();
  3094.  
  3095.     fclose(fMakeFile);
  3096.     
  3097.     // The makefile is opened with a creator of 'TTXT'
  3098.     // The easiest way to patch it is in the script
  3099.     this->Execute("SetFile -c 'MPS ' \"" + makeFileName + "\"");
  3100. }
  3101.  
  3102. //----------------------------------------------------------------------------------------
  3103. // TMABuildTool::CatenateMake: 
  3104. //----------------------------------------------------------------------------------------
  3105. #pragma segment ANonRes
  3106.  
  3107. void TMABuildTool::CatenateMake(const CStr255& fileName)
  3108. {
  3109.     CatenateFile(fileName, fMakeFile);
  3110. }
  3111.  
  3112. //----------------------------------------------------------------------------------------
  3113. // TMABuildTool::MakeTarget: 
  3114. //----------------------------------------------------------------------------------------
  3115. #pragma segment ANonRes
  3116.  
  3117. void TMABuildTool::MakeTarget()
  3118. {
  3119.     // run make
  3120.     this->Execute("{MAMake} {MakeOptions} ∂");
  3121.     this->Execute("-f \"{ObjApp}{XAppName}.make\" ∂");
  3122.  
  3123.     // Supply a target
  3124.     if (fRSRC)
  3125.     {
  3126.         if (fAppName == "MacApp.lib.xcoff")
  3127.             this->Execute("\"{ObjApp}MacApp.Lib.π.rsrc\" ∂");
  3128.         else
  3129.             this->Execute("\"{ObjApp}{XAppName}.π.rsrc\" ∂");
  3130.     }
  3131.     else
  3132.         this->Execute("\"{ObjApp}{XAppName}\" ∂");
  3133.     
  3134.     if (!fStatusOnly)
  3135.         this->Execute(">> \"{XMakeIt}\"");
  3136.     else
  3137.         this->Execute("");
  3138. }
  3139.  
  3140. //----------------------------------------------------------------------------------------
  3141. // TMABuildTool::DoOverrides: 
  3142. //----------------------------------------------------------------------------------------
  3143. #pragma segment TRes
  3144.  
  3145. void TMABuildTool::DoOverrides()
  3146. {
  3147.     // MacApp as library support
  3148.     if (fMALibrary)
  3149.         this->SetMakeVariable("MacAppObjs=");
  3150.     else
  3151.         this->SetMakeVariable("MacAppLibrary=");
  3152.  
  3153.     if (fCPlusLoad)
  3154.     {
  3155.         // If we don't have a RAM disk, just use the original C++ load files
  3156.         if (fRAMDisk)
  3157.             this->SetMakeVariable("CPlusLoadOriginal=");
  3158.         else
  3159.             this->SetMakeVariable("CPlusLoadCopy=");
  3160.     }
  3161.     else
  3162.     {
  3163.         this->SetMakeVariable("CPlusLoad=");
  3164.         this->SetMakeVariable("CPlusLoadObj=");
  3165.         this->SetMakeVariable("CPlusLoadOptions="); // Remove the definitions
  3166.         this->SetMakeVariable("CPlusLoadOriginal=");
  3167.         this->SetMakeVariable("CPlusLoadCopy=");
  3168.     }
  3169.     
  3170.     // Debugging support
  3171.     if (!fDebug)
  3172.     {
  3173.         this->SetMakeVariable("DebugFiles=");
  3174.         this->SetMakeVariable("DebugRsrcs=");
  3175.         this->SetMakeVariable("DebugLib="); // Eliminate debug files as targets in the makefiles
  3176.     }
  3177.     
  3178.     // Performance analysis support
  3179.     if (!fPerform)
  3180.         this->SetMakeVariable("PerformLib=");
  3181.     
  3182.     if (fCompiler == kwMWC68K || fCompiler == kwMWCPPC)
  3183.     {
  3184.         this->SetMakeVariable("MAPrefixFile=");
  3185.         this->SetMakeVariable("LoadFileOutput=");
  3186.         this->SetMakeVariable("Stubs=");
  3187.     }
  3188.     else
  3189.     {
  3190.         this->SetMakeVariable("CLoadOptions=");
  3191.         this->SetMakeVariable("CWPrefixFile=");
  3192.     }
  3193.  
  3194.     if (fCompiler == kwMWC68K)
  3195.     {
  3196.         // Select the proper CodeWarrior floating point support
  3197.         if (fNeedsFPU)
  3198.         {
  3199.             this->SetMakeVariable("CWLibrariesNoFPU=");
  3200.             this->SetMakeVariable("CWNearNonFPUStdCLib=");
  3201.             this->SetMakeVariable("CWFarNonFPUStdCLib=");
  3202.             this->SetMakeVariable("CWToolNearNonFPUStdCLib=");
  3203.             this->SetMakeVariable("CWToolFarNonFPUStdCLib=");
  3204.         }
  3205.         else
  3206.         {
  3207.             this->SetMakeVariable("CWFPUSANELib=");
  3208.             this->SetMakeVariable("CWNearFPUStdCLib=");
  3209.             this->SetMakeVariable("CWFarFPUStdCLib=");
  3210.             this->SetMakeVariable("CWToolNearFPUStdCLib=");
  3211.             this->SetMakeVariable("CWToolFarFPUStdCLib=");
  3212.         }
  3213.         
  3214.         // Select the proper CodeWarrior run-time model
  3215.         if (fModelFarData || fModelFar)
  3216.         {
  3217.             this->SetMakeVariable("CWNearFPUStdCLib=");
  3218.             this->SetMakeVariable("CWNearNonFPUStdCLib=");
  3219.             this->SetMakeVariable("CWToolNearFPUStdCLib=");
  3220.             this->SetMakeVariable("CWToolNearNonFPUStdCLib=");
  3221.         }
  3222.         else
  3223.         {
  3224.             this->SetMakeVariable("CWFarNonFPUStdCLib=");
  3225.             this->SetMakeVariable("CWFarFPUStdCLib=");
  3226.             this->SetMakeVariable("CWToolFarNonFPUStdCLib=");
  3227.             this->SetMakeVariable("CWToolFarFPUStdCLib=");
  3228.         }
  3229.     }
  3230.     else if (!fPowerPC)
  3231.     {
  3232.         // Select the proper floating point support
  3233.         if (fNeedsFPU)
  3234.             this->SetMakeVariable("LibrariesNoFPU=");
  3235.         else
  3236.             this->SetMakeVariable("LibrariesFPU=");
  3237.  
  3238.         // Select the proper link libraries for modelfar support by eliminating
  3239.         // the definition of ModelFarSupport if it's not used
  3240.         if (!fModelFar)
  3241.             this->SetMakeVariable("ModelFarSupport=");
  3242.     }
  3243.  
  3244.     // Drag & Drop Support
  3245.     if (!fDrag)
  3246.     {
  3247.         // Knock out the Drag & Drop support
  3248.         this->SetMakeVariable("DragLib=");
  3249.         if (fPowerPC || fModelCFM)
  3250.             this->SetMakeVariable("DragLibMapping=");
  3251.     }
  3252.     
  3253.     // PowerTalk Mailer Support
  3254.     if (!fPowerTalk)
  3255.     {
  3256.         // Knock out the AOCE support
  3257.         this->SetMakeVariable("AOCELib=");
  3258.         if (fPowerPC || fModelCFM)
  3259.             this->SetMakeVariable("AOCELibMapping=");
  3260.     }
  3261.         
  3262.     //GXPrinting Support
  3263.     if (!fGXPrinting)
  3264.     {
  3265.         // Knock out the GX support
  3266.         this->SetMakeVariable("GXLib=");
  3267.         if (fPowerPC || fModelCFM)
  3268.             this->SetMakeVariable("GXLibMapping=");
  3269.     }
  3270. }
  3271.  
  3272. //----------------------------------------------------------------------------------------
  3273. // TMABuildTool::DoDefinitions: 
  3274. //----------------------------------------------------------------------------------------
  3275. #pragma segment ANonRes
  3276.  
  3277. void TMABuildTool::DoDefinitions()
  3278. {
  3279.     CStr255 MADependencies;
  3280.     IEgetenv("MADependencies", MADependencies);
  3281.     
  3282.     // RSRC has to go first because it overrides PPC or 68K
  3283.     if (fRSRC)
  3284.         this->CatenateMake(MADependencies + "Definitions_RSRC");
  3285.     else
  3286.     {
  3287.         this->CatenateMake(MADependencies + "Definitions_Common");
  3288.         
  3289.         if (fPowerPC)
  3290.         {
  3291.             this->CatenateMake(MADependencies + "Definitions_PPC");
  3292.             if (fCompiler == kwMrC)
  3293.                 this->CatenateMake(MADependencies + "Definitions_MrC");
  3294.             else if (fCompiler == kwMWCPPC)
  3295.                 this->CatenateMake(MADependencies + "Definitions_MWPPC");
  3296.             else
  3297.                 this->CatenateMake(MADependencies + "Definitions_PPCC");
  3298.         }
  3299.         else
  3300.         {
  3301.             this->CatenateMake(MADependencies + "Definitions_68K");
  3302.             if (fModelCFM)
  3303.                 this->CatenateMake(MADependencies + "Definitions_CFM68K");
  3304.             else if (fClassic)
  3305.                 this->CatenateMake(MADependencies + "Definitions_Classic");
  3306.             else if (fCompiler == kwSCpp)
  3307.                 this->CatenateMake(MADependencies + "Definitions_SC");
  3308.             else if (fCompiler == kwMWC68K)
  3309.                 this->CatenateMake(MADependencies + "Definitions_MW68K");
  3310.         }
  3311.     }
  3312. }
  3313.  
  3314. //----------------------------------------------------------------------------------------
  3315. // TMABuildTool::DoDependencies: 
  3316. //----------------------------------------------------------------------------------------
  3317. #pragma segment ANonRes
  3318.  
  3319. void TMABuildTool::DoDependencies()
  3320. {
  3321.     CStr255 MADependencies;
  3322.     IEgetenv("MADependencies", MADependencies);
  3323.     
  3324.     // RSRC has to go first because it overrides PPC or 68K
  3325.     if (fRSRC)
  3326.         this->CatenateMake(MADependencies + "Dependencies_RSRC");
  3327.     else if (fPowerPC)
  3328.     {
  3329.         if (fFast)
  3330.             this->CatenateMake(MADependencies + "Fast_Dependencies_PPC");
  3331.         else
  3332.             this->CatenateMake(MADependencies + "Dependencies_PPC");
  3333.     }
  3334.     else
  3335.     {
  3336.         if (fFast)
  3337.             this->CatenateMake(MADependencies + "Fast_Dependencies_68K");
  3338.         else
  3339.             this->CatenateMake(MADependencies + "Dependencies_68K");
  3340.     }
  3341. }
  3342.  
  3343. //----------------------------------------------------------------------------------------
  3344. // TMABuildTool::SetMakeVariable: 
  3345. //----------------------------------------------------------------------------------------
  3346. #pragma segment ANonRes
  3347.  
  3348. void TMABuildTool::SetMakeVariable(const CStr255& theVariable,
  3349.                                    TStringHandle* theValue)
  3350. {
  3351.     fprintf(fMakeFile, "%s = ", (const char *)theVariable);
  3352.     theValue->WriteToFile(fMakeFile);
  3353.     fprintf(fMakeFile, "\n");
  3354. }
  3355.  
  3356. //----------------------------------------------------------------------------------------
  3357. // TMABuildTool::SetMakeVariable: 
  3358. //----------------------------------------------------------------------------------------
  3359. #pragma segment ANonRes
  3360.  
  3361. void TMABuildTool::SetMakeVariable(const CStr255& theVariable,
  3362.                                    const CStr255& theValue)
  3363. {
  3364.     fprintf(fMakeFile, "%s = %s\n", (const char *)theVariable, (const char *)theValue);
  3365. }
  3366.  
  3367. //----------------------------------------------------------------------------------------
  3368. // TMABuildTool::SetMakeVariable: 
  3369. //----------------------------------------------------------------------------------------
  3370. #pragma segment ANonRes
  3371.  
  3372. void TMABuildTool::SetMakeVariable(const CStr255& theVariable,
  3373.                                    Boolean theValue)
  3374. {
  3375.     short boolAsShort = theValue;
  3376.     fprintf(fMakeFile, "%s = %i\n", (const char *)theVariable, boolAsShort);
  3377. }
  3378.  
  3379. //----------------------------------------------------------------------------------------
  3380. // TMABuildTool::SetMakeVariable: 
  3381. //----------------------------------------------------------------------------------------
  3382. #pragma segment ANonRes
  3383.  
  3384. void TMABuildTool::SetMakeVariable(const CStr255& aString)
  3385. {
  3386.     fprintf(fMakeFile, "%s\n", (const char *)aString);
  3387. }
  3388.  
  3389. //----------------------------------------------------------------------------------------
  3390. // TMABuildTool::SetMakeIE: 
  3391. //----------------------------------------------------------------------------------------
  3392. #pragma segment ANonRes
  3393.  
  3394. void TMABuildTool::SetMakeIE(const CStr255& theVariable)
  3395. {
  3396.     CStr255 theValue;
  3397.     IEgetenv(theVariable, theValue);
  3398.     fprintf(fMakeFile, "%s = %s\n", (const char *)theVariable, (const char *)theValue);
  3399. }
  3400.  
  3401. //----------------------------------------------------------------------------------------
  3402. // TMABuildTool::SetMakeIE: 
  3403. //----------------------------------------------------------------------------------------
  3404. #pragma segment ANonRes
  3405.  
  3406. void TMABuildTool::SetMakeIE(const CStr255& theVariable,
  3407.                              const CStr255& theIEVariable)
  3408. {
  3409.     CStr255 theValue;
  3410.     IEgetenv(theIEVariable, theValue);
  3411.     fprintf(fMakeFile, "%s = %s\n", (const char *)theVariable, (const char *)theValue);
  3412. }
  3413.  
  3414. //----------------------------------------------------------------------------------------
  3415. // TMABuildTool::OutputMakeVariables: 
  3416. //----------------------------------------------------------------------------------------
  3417. #pragma segment ANonRes
  3418.  
  3419. void TMABuildTool::OutputMakeVariables()
  3420. {
  3421.     // output the results.
  3422.     //    if (fTimes)
  3423.     //        fprintf(fOutputFile," Echo XStartTime = %li\n", fStartDateTime);
  3424.     
  3425.     this->SetMakeVariable("XTimes", fTimes);
  3426.     this->SetMakeVariable("XRunAfterBuild", fRunAfterBuild);
  3427.     this->SetMakeVariable("XUseRAMDisk", fRAMDisk && fCPlusLoad);
  3428.     this->SetMakeVariable("XRAMDiskName", fRAMDiskName);
  3429.     //    if (fRAMDisk && fCPlusLoad)
  3430.     //        this->SetMakeVariable("XRAMDiskLoad = 0");
  3431.     this->SetMakeVariable("LoadFileDir", fObjApp);
  3432.     
  3433.     this->SetMakeIE("CIncludes");
  3434.     this->SetMakeIE("MACPlusIncludes");
  3435.     this->SetMakeIE("MARIncludes");
  3436.     this->SetMakeIE("MALibraries");
  3437.  
  3438.     this->SetMakeIE("MAAsmPaths");
  3439.     this->SetMakeIE("MACPlusPaths");
  3440.     this->SetMakeIE("MARezPaths");
  3441.  
  3442.     this->SetMakeIE("MAApp");
  3443.     this->SetMakeIE("MACore");
  3444.     this->SetMakeIE("MADocs");
  3445.     this->SetMakeIE("MAFramework");
  3446.     this->SetMakeIE("MAMail");
  3447.     this->SetMakeIE("MATool");
  3448.     this->SetMakeIE("MAViews");
  3449.  
  3450.     this->SetMakeIE("MAAsm");
  3451.     this->SetMakeIE("MAC");
  3452.     this->SetMakeIE("MACPlus");
  3453.     this->SetMakeIE("MAEcho");
  3454.     this->SetMakeIE("MALib");
  3455.     this->SetMakeIE("MARez");
  3456.     
  3457.     this->SetMakeVariable("AsmOptions", fAsmOptions);
  3458.         
  3459.     if (!fPowerPC)
  3460.     {
  3461.         if (fCompiler == kwMWC68K )
  3462.         {
  3463.             this->SetMakeVariable("CPlusOptions", fMWC68KOptions);
  3464.             this->SetMakeVariable("COptions", fMWC68KOptions);
  3465.             this->SetMakeVariable("SCOptions =");
  3466.             this->SetMakeIE("MAC", "MAmwc68K");
  3467.             this->SetMakeIE("MACPlus", "MAmwc68K");
  3468.         }
  3469.         else
  3470.         {
  3471.             this->SetMakeVariable("COptions", fCOptions);
  3472.  
  3473.             if (fCompiler == kwSCpp)
  3474.             {
  3475.                 this->SetMakeVariable("CPlusOptions =");
  3476.                 this->SetMakeVariable("MAC = SC");
  3477.                 this->SetMakeIE("MACPlus", "MASCpp");
  3478.                 this->SetMakeVariable("SCOptions", fSCOptions);
  3479.             }
  3480.             else
  3481.             {
  3482.                 this->SetMakeVariable("SCOptions =");
  3483.                 this->SetMakeVariable("CPlusOptions", fCPlusOptions);
  3484.             }
  3485.         }
  3486.         this->SetMakeVariable("CPlusCPUOptions", fCPlusCPUOptions);
  3487.     }
  3488.     else // fPowerPC
  3489.     {
  3490.         this->SetMakeVariable("PPCAsmOptions", fPPCAsmOptions);
  3491.         
  3492.         if (fCompiler == kwMWCPPC)
  3493.         {
  3494.             this->SetMakeIE("MAPPCC", "MAmwCPPC");
  3495.             this->SetMakeIE("MAPPCLink", "MAmwLinkPPC");
  3496.             this->SetMakeVariable("MrCOptions =");
  3497.             this->SetMakeVariable("PPCCOptions", fMWCPPCOptions);
  3498.         }
  3499.         else if (fCompiler == kwMrC)
  3500.         {
  3501.             this->SetMakeVariable("PPCCOptions =");
  3502.             this->SetMakeIE("MAPPCC", "MAMrCPlus");
  3503.             this->SetMakeVariable("MrCOptions", fMrCOptions);
  3504.         }
  3505.         else
  3506.         {
  3507.             this->SetMakeVariable("MrCOptions =");
  3508.             this->SetMakeVariable("PPCCOptions", fPPCCOptions);
  3509.         }
  3510.     }
  3511.  
  3512.     this->SetMakeVariable("EchoOptions", fEchoOptions);
  3513.             
  3514.     if (fCompiler == kwMWC68K)
  3515.     {
  3516.         this->SetMakeIE("MALink", "MAmwLink68K");
  3517.         this->SetMakeVariable("LinkOptions", fMWLink68KOptions);
  3518.         this->SetMakeIE("MALib", "MAmwLink68K");
  3519.         
  3520.         fprintf(fMakeFile, "LibOptions = -library ");
  3521.         fMWLink68KOptions->WriteToFile(fMakeFile);
  3522.         fprintf(fMakeFile, "\n");
  3523.     }
  3524.     else
  3525.     {
  3526.         this->SetMakeVariable("LibOptions", fLibOptions);
  3527.         this->SetMakeVariable("LinkOptions", fLinkOptions);
  3528.     }
  3529.     
  3530.     if (fModelCFM)
  3531.     {
  3532.         this->SetMakeIE("MALink", "MAILink");
  3533.     }
  3534.     
  3535.     if (fPowerPC)
  3536.     {
  3537.         if (fCompiler == kwMWCPPC)
  3538.         {
  3539.             fprintf(fMakeFile, "PPCLibOptions =  -xm library ");
  3540.             fMWLinkPPCOptions->WriteToFile(fMakeFile);
  3541.             fprintf(fMakeFile, "\n");
  3542.  
  3543.             this->SetMakeVariable("PPCLinkOptions", fMWLinkPPCOptions);
  3544.         }
  3545.         else
  3546.         {
  3547.             this->SetMakeVariable("PPCLibOptions", fPPCLibOptions);
  3548.             this->SetMakeVariable("PPCLinkOptions", fPPCLinkOptions);
  3549.         }
  3550.         
  3551.         this->SetMakeVariable("MakeSymOptions", fMakeSymOptions);
  3552.     }
  3553.     
  3554.     this->SetMakeVariable("RunTimeModel", fRunTimeModel);
  3555.     
  3556.     if (fCompiler == kwMWC68K || fCompiler == kwMWCPPC)
  3557.         this->SetMakeIE("CIncludes", "CWExtraFiles");
  3558.  
  3559.     //    if (fFast)
  3560.     //    {
  3561.     //        fprintf(fOutputFile, "SET All_Cpp_Files \"\"\n");
  3562.     //        fprintf(fOutputFile, "SET All_Cpp_Names \"\"\n");
  3563.     //        fprintf(fOutputFile, "SET All_C_Files \"\"\n");
  3564.     //        fprintf(fOutputFile, "SET All_C_Names \"\"\n");
  3565.     //    }
  3566.  
  3567.     //this->SetMakeVariable("MakeOptions", fMakeOptions);
  3568.     this->SetMakeVariable("RezOptions", fRezOptions);
  3569.     this->SetMakeVariable("CreatorAndBundleOptions", fCreatorAndBundleOptions);
  3570.     this->SetMakeVariable("XOptionFlags", fOptionFlags);
  3571.     
  3572.     this->SetMakeVariable("SeparateObjectsFolder", fSeparateObjectsFolder);
  3573.     this->SetMakeVariable("BuildFolder", fBuildFolder);
  3574.     this->SetMakeVariable("MAObj", fMAObj);
  3575.     this->SetMakeVariable("XAppPath", fAppPath);
  3576.     this->SetMakeVariable("ObjApp", fObjApp);
  3577.     this->SetMakeVariable("SrcApp", fSrcApp);
  3578.     this->SetMakeVariable("IncApp", fIncApp);
  3579.  
  3580.     this->SetMakeVariable("XLinkMap", fXLinkMap);
  3581.     this->SetMakeVariable("XLinkXRef", fXLinkXRef);
  3582.  
  3583.     this->SetMakeVariable("XAppName", fAppName);
  3584.     this->SetMakeVariable("XUAppName.h", fXUAppName_h);
  3585.     this->SetMakeVariable("XUAppName.cp", fXUAppName_cp);
  3586.     this->SetMakeVariable("XUAppName.cp.o", fXUAppName_cp_o);
  3587.     this->SetMakeVariable("XMAppName.cp", fXMAppName_cp);
  3588.     this->SetMakeVariable("XMAppName.cp.o", fXMAppName_cp_o);
  3589.     this->SetMakeVariable("XAppName.cp", fXAppName_cp);
  3590.     this->SetMakeVariable("XAppName.cp.o", fXAppName_cp_o);
  3591.     
  3592.     this->SetMakeVariable("XAutoRez", fAutorez);
  3593.     if (fAutorez)
  3594.         this->SetMakeVariable("XAppRezSrc", "{MAFramework}Includes:Default.r");
  3595.     else
  3596.         this->SetMakeVariable("XAppRezSrc", fAppPath + fAppName + ".r");
  3597.  
  3598.     this->SetMakeVariable("BuildFlags", fBuildFlags);
  3599.     this->SetMakeVariable("XMakeIt", fObjApp + fAppName + "{MAMakeOutfileExtension}");
  3600. }
  3601.  
  3602. //----------------------------------------------------------------------------------------
  3603. // TMABuildTool::OutputTheEnd: 
  3604. //----------------------------------------------------------------------------------------
  3605. #pragma segment ANonRes
  3606.  
  3607. void TMABuildTool::OutputTheEnd()
  3608. {
  3609.     // Close the output file.
  3610.     if (fOutputFile != stdout)
  3611.         fclose(fOutputFile);
  3612.         
  3613.     // termination messages
  3614.     if (fTimes)
  3615.     {
  3616.         this->Echo("\" \"");
  3617.         this->Echo("MABuild:   Elapsed time: `evaluate ∂`DATE -n∂` - {XStartTime}` seconds");
  3618.     }
  3619.  
  3620.     this->Execute("IF \"{XExitStatus}\"");
  3621.     this->Execute("{MAFailed}");
  3622.     this->Execute("EXIT \"{XExitStatus}\"");
  3623.     this->Execute("END");
  3624.  
  3625.     if (fProgress)
  3626.     {
  3627.         this->Echo("Completion time for MABuild is `DATE`");
  3628.         this->Execute("{MADone}");
  3629.     }
  3630. }
  3631.  
  3632. //----------------------------------------------------------------------------------------
  3633. // TMABuildTool::SetOutputFile:
  3634. //----------------------------------------------------------------------------------------
  3635. #pragma segment ANonRes
  3636.  
  3637. void TMABuildTool::SetOutputFile(const CStr255& outputFileName)
  3638. {
  3639.     fOutputFile = fopen(outputFileName, "w");
  3640.     if (fOutputFile == NULL)
  3641.     {
  3642.         this->Stop("MABuild: Unable to create or open output file.");
  3643.     }
  3644. }
  3645.  
  3646. //----------------------------------------------------------------------------------------
  3647. // TMABuildTool::DoToolAction: 
  3648. //----------------------------------------------------------------------------------------
  3649. #pragma segment ANonRes
  3650.  
  3651. void TMABuildTool::DoToolAction()
  3652. {
  3653.     {
  3654.         CStr255 MAShortVersion;
  3655.         if (!IEgetenv("MAShortVersion", MAShortVersion))
  3656.         {
  3657.             this->Stop("MABuild: Whoops… You have not executed the Startup file in the MacApp directory");
  3658.         }
  3659.         else if (MAShortVersion != MA_SHORT_VERSION)
  3660.         {
  3661.             fprintf(stderr, "\nMABuild: Warning: The MacApp version seems to be '%s'; should be '%s'\n",
  3662.                     (const char *) MAShortVersion, MA_SHORT_VERSION);
  3663.         }
  3664.     }
  3665.     
  3666.     // Resolve matrix of options.
  3667.     this->CheckKeywords();
  3668.  
  3669.     // Set up the option flags.
  3670.     this->DoOptionFlags_Part1();
  3671.     this->DoOptionFlags_Part2();
  3672.     
  3673.     if (fGetBuildFlags || fGetFolderName)
  3674.     {
  3675.         if (fGetFolderName)
  3676.             this->Execute("ECHO \"{SeparateObjectsFolder}\"");
  3677.         else
  3678.         {
  3679.             fprintf(fOutputFile, "SET XOptionFlags \"");
  3680.             fOptionFlags->WriteToFile(fOutputFile);
  3681.             fprintf(fOutputFile, "\"\n");
  3682.             this->Execute("ECHO \"{XOptionFlags}\"");
  3683.         }
  3684.         return;
  3685.     }
  3686.     
  3687.     // Get the autobuild targets, if any.
  3688.     this->GetAutoBuild();
  3689.  
  3690.     // output the results.
  3691.     this->OutputOptionFlags();
  3692.  
  3693.     // Process autosave
  3694.     if (fSaveBeforeBuild)
  3695.     {
  3696.         if (fProgress)
  3697.             this->Echo("\"AutoSaving…\"");
  3698.         this->Execute("Save -a");
  3699.     }
  3700.  
  3701.     // Remember the current directory
  3702.     short vRefNum;
  3703.     long dirID;
  3704.     if (HGetVol(NULL, &vRefNum, &dirID) == noErr)
  3705.         PathNameFromDirID(dirID, vRefNum, fStartPath);
  3706.  
  3707.     // Create the alternate build folder
  3708.     this->CreateBuildFolder();
  3709.     
  3710.     // process each target in the list
  3711.     this->DoAllTargets();
  3712.  
  3713.     // termination messages
  3714.     this->OutputTheEnd();
  3715. }
  3716.  
  3717. //----------------------------------------------------------------------------------------
  3718. // main: 
  3719. //----------------------------------------------------------------------------------------
  3720. #pragma segment Main
  3721.  
  3722. void main(int argc, char** argv)
  3723. {
  3724.     InitUCPlusTool();
  3725.     
  3726.     gMABuildTool = new TMABuildTool;
  3727.     gMABuildTool->IMABuildTool(argc, argv);
  3728.     gMABuildTool->Run();
  3729. }
  3730.  
  3731. //----------------------------------------------------------------------------------------
  3732. // End of MABuildTool.cp
  3733.  
  3734. #pragma segment Inline
  3735.